github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/generator/templates/simpleschema/defaultsvar.gotmpl (about) 1 {{- varname .ID}}Default 2 {{- if .IsPrimitive }} 3 {{- print " " }}={{ print " " }} 4 {{- if .IsCustomFormatter }} 5 {{- if stringContains .Zero "(\"" }} 6 {{- .GoType }}({{ printf "%#v" .Default }}){{/* strfmt type initializer that takes string */}} 7 {{- else }} 8 {{- .Zero }}{{/* strfmt type initializer that requires UnmarshalText(), e.g. Date, Datetime, Duration */}} 9 {{- end }} 10 {{- else }} 11 {{- .GoType }}({{ printf "%#v" .Default }}){{/* regular go primitive type initializer */}} 12 {{- end }} 13 {{- else if .IsArray }}{{/* do not initialize from possible defaults in nested arrays */}} 14 {{- if .Child.IsPrimitive }} 15 {{- print " " }}={{ print " " }} 16 {{- if .Child.IsCustomFormatter }} 17 {{- .Zero }}{{/* initialization strategy with UnmarshalText() */}} 18 {{- else }} 19 {{- .GoType }}{{ arrayInitializer .Default }}{{/* regular go primitive type initializer: simple slice initializer */}} 20 {{- end }} 21 {{- else if .Child.IsArray }} 22 {{- print " " }}={{ print " " }} 23 {{- .Zero }}{{/* initialization strategy with json.Unmarshal() */}} 24 {{- else }} 25 {{- print " " }}{{ .GoType }}{{/* shouldn't have that: simple schema is either primitive or array */}} 26 {{- end }} 27 {{- else }} 28 {{- print " " }}{{ .GoType }}{{/* shouldn't have that: simple schema is either primitive or array */}} 29 {{- end }}