You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
)
typecfgstruct {
MySettingstring`json:"JSONMySetting",toml:"toml_my_setting"`// Does not work//MySetting string `toml:"toml_my_setting",json:"JSONMySetting"` // Works
}
funcmain() {
c1:=cfg{"foo"}
data, err:=toml.Marshal(&c1)
iferr!=nil {
panic(err)
}
fmt.Printf("Serialized: %s", string(data))
varc2cfgiferr:=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:
The text was updated successfully, but these errors were encountered: