@@ 21,7 21,9 @@ package {{.package}}
// Code generated by go-bare/cmd/gen, DO NOT EDIT.
import (
+{{- if .schema.NeedErrors }}
"errors"
+{{- end }}
"git.sr.ht/~sircmpwn/go-bare"
)
@@ 248,9 250,10 @@ func parseArgs() *Config {
}
type Types struct {
- UserTypes []*schema.UserDefinedType
- Enums []*schema.UserDefinedEnum
- Unions []*schema.UserDefinedType
+ UserTypes []*schema.UserDefinedType
+ Enums []*schema.UserDefinedEnum
+ Unions []*schema.UserDefinedType
+ NeedErrors bool
}
func parseSchema(path string, skip map[string]bool) Types {
@@ 286,5 289,9 @@ func parseSchema(path string, skip map[string]bool) Types {
}
}
+ if len(types.Enums) > 0 {
+ types.NeedErrors = true
+ }
+
return types
}