File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -98,9 +98,9 @@ Given the following struct, let's see how to read it and write it as TOML:
98
98
99
99
``` go
100
100
type MyConfig struct {
101
- Version int
102
- Name string
103
- Tags []string
101
+ Version int
102
+ Name string
103
+ Tags []string
104
104
}
105
105
```
106
106
@@ -119,7 +119,7 @@ tags = ["go", "toml"]
119
119
var cfg MyConfig
120
120
err := toml.Unmarshal ([]byte (doc), &cfg)
121
121
if err != nil {
122
- panic (err)
122
+ panic (err)
123
123
}
124
124
fmt.Println (" version:" , cfg.Version )
125
125
fmt.Println (" name:" , cfg.Name )
@@ -140,14 +140,14 @@ as a TOML document:
140
140
141
141
``` go
142
142
cfg := MyConfig {
143
- Version : 2 ,
144
- Name : " go-toml" ,
145
- Tags : []string {" go" , " toml" },
143
+ Version : 2 ,
144
+ Name : " go-toml" ,
145
+ Tags : []string {" go" , " toml" },
146
146
}
147
147
148
148
b , err := toml.Marshal (cfg)
149
149
if err != nil {
150
- panic (err)
150
+ panic (err)
151
151
}
152
152
fmt.Println (string (b))
153
153
@@ -293,16 +293,16 @@ element in the interface to decode the object. For example:
293
293
294
294
``` go
295
295
type inner struct {
296
- B interface {}
296
+ B interface {}
297
297
}
298
298
type doc struct {
299
- A interface {}
299
+ A interface {}
300
300
}
301
301
302
302
d := doc{
303
- A : inner{
304
- B: " Before" ,
305
- },
303
+ A : inner{
304
+ B: " Before" ,
305
+ },
306
306
}
307
307
308
308
data := `
@@ -341,7 +341,7 @@ contained in the doc is superior to the capacity of the array. For example:
341
341
342
342
``` go
343
343
type doc struct {
344
- A [2 ]string
344
+ A [2 ]string
345
345
}
346
346
d := doc{}
347
347
err := toml.Unmarshal ([]byte (` A = ["one", "two", "many"]` ), &d)
You can’t perform that action at this time.
0 commit comments