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
I make TOML support for nicksnyder/goi18n library, but become an issue when trying to marshal some objects: cannot convert type *translation.template to TomlTree. *translation.template have String method though, so we can use it for marshaling.
Code:
m, ok:=v.(map[string]interface{})
if!ok {
returnnil, fmt.Errorf("invalid format for marshaling to TOML")
}
tree, err:=toml.TreeFromMap(m)
iferr!=nil {
returnnil, err
}
s, err:=tree.ToTomlString()
return []byte(s), err
Example of m:
map[person_unread_email_count:map[one:{{.Person}} has {{.Count}} unread email. other:{{.Person}}
has{{.Count}} unread emails.] person_unread_email_count_timeframe:map[other:{{.Person}} has
{{.Count}} unread email in the past {{.Timeframe}}.] program_greeting:map[other:Hello world]
your_unread_email_count:map[one:You have {{.Count}} unread email. other:You have {{.Count}}
unread emails.] d_days:map[other:this should get overwritten] my_height_in_meters:map[one:I am
{{.Count}} meter tall. other:I am {{.Count}} meters tall.] person_greeting:map[other:Hello
{{.Person}}]]
I make TOML support for nicksnyder/goi18n library, but become an issue when trying to marshal some objects:
cannot convert type *translation.template to TomlTree
. *translation.template have String method though, so we can use it for marshaling.Code:
Example of
m
:More information you can find here.
The text was updated successfully, but these errors were encountered: