-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any example present how to use message format in JSON #238
Comments
key point:
example code👆 where simpleTest Other: custom formatdefault is support TOML, YAML, JSON If the above format is not satisfied for you, you can define your // UnmarshalFunc unmarshals data into v.
type UnmarshalFunc func(data []byte, v interface{}) error normally v should be something like this: map[string]interface{} I mean, suppose your contents is below
|
There is a TOML example here and you can just convert that file to an equivalent JSON file using a converter like https://pseitz.github.io/toml-to-json-online-converter/ to get the equivalent JSON file: {
"HelloPerson": "Hello {{.Name}}",
"MyUnreadEmails": {
"description": "The number of unread emails I have",
"one": "I have {{.PluralCount}} unread email.",
"other": "I have {{.PluralCount}} unread emails."
},
"PersonUnreadEmails": {
"description": "The number of unread emails a person has",
"one": "{{.Name}} has {{.UnreadEmailCount}} unread email.",
"other": "{{.Name}} has {{.UnreadEmailCount}} unread emails."
}
} There are also a JSON example in this test: Lines 101 to 118 in 7c6508d
|
Hi, i feel confuse on how to use message format in Json. Any demo example?
The text was updated successfully, but these errors were encountered: