signald-go/tools/generator/structs.go.tmpl

23 lines
782 B
Cheetah
Raw Normal View History

package {{.Version}}
2021-09-30 07:41:56 +00:00
// {{ .Banner }}
{{if gt (.ImportVersions | len) 0}}
import (
{{range $version := .ImportVersions}}
"gitlab.com/signald/signald-go/signald/client-protocol/{{$version}}"{{end}}
)
{{end}}
type Request struct {
2021-01-31 03:14:33 +00:00
ID string `json:"id" yaml:"id"`
Version string `json:"version" yaml:"version"`
Type string `json:"type" yaml:"type"`
}
{{ range $structName, $type := .Types }}{{if ne $type.Doc ""}}// {{$structName}}: {{$type.Doc}}{{end}}
type {{ $structName }} struct {
{{if $type.Request}} Request{{end}}
2021-01-31 03:14:33 +00:00
{{ range $fieldName, $field := $type.Fields }}{{ $field.FieldName }} {{if $field.List}}[]{{end}}{{ $field.Type }} `json:"{{$fieldName}},omitempty" yaml:"{{$fieldName}},omitempty"`{{if ne $field.Doc ""}} // {{$field.Doc}}{{end}}
{{ end }}}
{{ end }}