github.com/wawandco/oxpecker@v1.5.7-0.20210910201653-5958d4afdd89/tools/buffalo/model/templates/newmodel.go.tmpl (about)

     1  package models
     2  
     3  import (
     4  	{{- range $i := .Imports }}
     5  	"{{$i}}"
     6  	{{- end }}
     7  )
     8  
     9  // {{ .Name.Proper.String }} model struct.
    10  type {{ .Name.Proper.String }} struct {
    11  	{{- range $attr := .Attrs }}
    12  	{{ $attr.Name.Pascalize }} {{$attr.GoType }} `json:"{{ $attr.Name.Underscore }}" db:"{{ $attr.Name.Underscore }}"`
    13  	{{- end }}
    14  }
    15  
    16  // {{ .Name.Proper.Pluralize }} array model struct of {{ .Name.Proper.String }}.
    17  type {{ .Name.Proper.Pluralize }} []{{ .Name.Proper.String }}
    18  
    19  // String converts the struct into a string value.
    20  func ({{ .Char }} {{ .Name.Proper.String }}) String() string {
    21  	return fmt.Sprintf("%+v\n", {{ .Char }})
    22  }