mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:32:05 +08:00
09.5 修改pack1包中变量名PackFloat为pack1Float,保持本节教程代码和文本的一致性。 (#631)
* 修改pack1包中变量名PackFloat为pack1Float * modify json.Decoder to json.NewDecoder
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
```go
|
```go
|
||||||
package pack1
|
package pack1
|
||||||
var Pack1Int int = 42
|
var Pack1Int int = 42
|
||||||
var PackFloat = 3.14
|
var pack1Float = 3.14
|
||||||
|
|
||||||
func ReturnStr() string {
|
func ReturnStr() string {
|
||||||
return "Hello main!"
|
return "Hello main!"
|
||||||
|
@@ -216,7 +216,7 @@ func NewDecoder(r io.Reader) *Decoder
|
|||||||
func NewEncoder(w io.Writer) *Encoder
|
func NewEncoder(w io.Writer) *Encoder
|
||||||
```
|
```
|
||||||
|
|
||||||
要想把 JSON 直接写入文件,可以使用 json.NewEncoder 初始化文件(或者任何实现 io.Writer 的类型),并调用 Encode();反过来与其对应的是使用 json.Decoder 和 Decode() 函数:
|
要想把 JSON 直接写入文件,可以使用 json.NewEncoder 初始化文件(或者任何实现 io.Writer 的类型),并调用 Encode();反过来与其对应的是使用 json.NewDecoder 和 Decode() 函数:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewDecoder(r io.Reader) *Decoder
|
func NewDecoder(r io.Reader) *Decoder
|
||||||
|
Reference in New Issue
Block a user