This commit is contained in:
Thomas Pelletier
2021-05-08 17:03:51 -04:00
committed by GitHub
parent ea225df3ed
commit 45ea20024b
8 changed files with 476 additions and 58 deletions
+25
View File
@@ -511,3 +511,28 @@ func TestIssue424(t *testing.T) {
require.NoError(t, err)
require.Equal(t, msg2, msg2parsed)
}
func ExampleMarshal() {
type MyConfig struct {
Version int
Name string
Tags []string
}
cfg := MyConfig{
Version: 2,
Name: "go-toml",
Tags: []string{"go", "toml"},
}
b, err := toml.Marshal(cfg)
if err != nil {
panic(err)
}
fmt.Println(string(b))
// Output:
// Version = 2
// Name = 'go-toml'
// Tags = ['go', 'toml']
}