If you have multiple struct field tags, and the first one isn't "toml" then it's ignored and the default logic kicks in for naming the fields in the serialized output.
Example:
package main
import (
"fmt"
"github.com/naoina/toml"
)
type cfg struct {
MySetting string `json:"JSONMySetting",toml:"toml_my_setting"` // Does not work
//MySetting string `toml:"toml_my_setting",json:"JSONMySetting"` // Works
}
func main() {
c1 := cfg{"foo"}
data, err := toml.Marshal(&c1)
if err != nil {
panic(err)
}
fmt.Printf("Serialized: %s", string(data))
var c2 cfg
if err := toml.Unmarshal(data, &c2); err != nil {
panic(err)
}
fmt.Printf("Unmarshaled: %#v\n", c2)
}
If you have multiple struct field tags, and the first one isn't "toml" then it's ignored and the default logic kicks in for naming the fields in the serialized output.
Example:
Expected output:
Actual output: