forked from mirrors/homebox
22 lines
772 B
Go
22 lines
772 B
Go
package automapper
|
|
|
|
var automapperTemplate = `// Code generated by "/pkgs/automapper"; DO NOT EDIT.
|
|
package {{ .Package }}
|
|
|
|
import (
|
|
{{ range $import := .Imports }}"{{ $import }}"
|
|
{{ end }}
|
|
)
|
|
|
|
func {{ .Schema.Reference }}FromModel(from {{ .Model.Prefix}}.{{ .Model.Reference }}) {{ .Schema.Prefix}}.{{ .Schema.Reference }} {
|
|
return {{ .Schema.Prefix}}.{{ .Schema.Reference }}{ {{ range $i, $f := .FieldAssignments }}
|
|
{{ $f.SchemaField }}: from.{{ $f.ModelField }},{{ end }}
|
|
}
|
|
}
|
|
|
|
func {{ .Schema.Reference }}ToModel(from {{ .Schema.Prefix}}.{{ .Schema.Reference }}) {{ .Model.Prefix}}.{{ .Model.Reference }} {
|
|
return {{ .Model.Prefix}}.{{ .Model.Reference }}{ {{ range $i, $f := .FieldAssignments }}
|
|
{{ $f.ModelField }}: from.{{ $f.SchemaField }},{{ end }}
|
|
}
|
|
}
|
|
`
|