github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/cmd/test/others/func/proto/defaults/sample.go (about) 1 package defaults 2 3 type Gender string 4 5 type Sample struct { 6 Name string `default:"John Smith"` 7 Age int `default:"27"` 8 Gender Gender `default:"m"` 9 10 Slice []string `default:"[]"` 11 SliceByJSON []int `default:"[1, 2, 3]"` // Supports JSON 12 Map map[string]int `default:"{}"` 13 MapByJSON map[string]int `default:"{\"foo\": 123}"` 14 15 Struct OtherStruct `default:"{}"` 16 StructPtr *OtherStruct `default:"{\"Foo\": 123}"` 17 18 NoTag OtherStruct // Recurses into a nested struct by default 19 OptOut OtherStruct `default:"-"` // Opt-out 20 } 21 22 type OtherStruct struct { 23 Hello string `default:"world"` // Tags in a nested struct also work 24 Foo int `default:"-"` 25 Random int `default:"-"` 26 }