Documentation ¶
Index ¶
- type DefaultFieldNamer
- type FieldNamer
- type Generator
- func (g *Generator) Add(obj interface{})
- func (g *Generator) NoStdMarshalers()
- func (g *Generator) OmitEmpty()
- func (g *Generator) Run(out io.Writer) error
- func (g *Generator) SetAdditionalTags(addlTags string)
- func (g *Generator) SetBuildTags(tags string)
- func (g *Generator) SetFieldNamer(n FieldNamer)
- func (g *Generator) SetPkg(name, path string)
- func (g *Generator) UseLowerCamelCase()
- func (g *Generator) UseSnakeCase()
- type LowerCamelCaseFieldNamer
- type SnakeCaseFieldNamer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultFieldNamer ¶
type DefaultFieldNamer struct {
// contains filtered or unexported fields
}
DefaultFieldsNamer implements trivial naming policy equivalent to encoding/json.
func (DefaultFieldNamer) GetJSONFieldName ¶
func (dfn DefaultFieldNamer) GetJSONFieldName(t reflect.Type, f reflect.StructField) string
func (DefaultFieldNamer) GetTagName ¶
func (dfn DefaultFieldNamer) GetTagName() string
func (DefaultFieldNamer) GetTagValue ¶
func (dfn DefaultFieldNamer) GetTagValue(f reflect.StructField) string
type FieldNamer ¶
type FieldNamer interface { GetTagName() string GetTagValue(f reflect.StructField) string GetJSONFieldName(t reflect.Type, f reflect.StructField) string }
FieldNamer defines a policy for generating names for struct fields.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates the requested marshaler/unmarshalers.
func NewGenerator ¶
NewGenerator initializes and returns a Generator.
func (*Generator) Add ¶
func (g *Generator) Add(obj interface{})
Add requests to generate marshaler/unmarshalers and encoding/decoding funcs for the type of given object.
func (*Generator) NoStdMarshalers ¶
func (g *Generator) NoStdMarshalers()
NoStdMarshalers instructs not to generate standard MarshalJSON/UnmarshalJSON methods (only the custom interface).
func (*Generator) OmitEmpty ¶
func (g *Generator) OmitEmpty()
OmitEmpty triggers `json=",omitempty"` behaviour by default.
func (*Generator) SetAdditionalTags ¶
func (*Generator) SetBuildTags ¶
SetBuildTags sets build tags for the output file.
func (*Generator) SetFieldNamer ¶
func (g *Generator) SetFieldNamer(n FieldNamer)
SetFieldNamer sets field naming strategy.
func (*Generator) UseLowerCamelCase ¶
func (g *Generator) UseLowerCamelCase()
UseLowerCamelCase sets lowerCamelCase field naming strategy.
func (*Generator) UseSnakeCase ¶
func (g *Generator) UseSnakeCase()
UseSnakeCase sets snake_case field naming strategy.
type LowerCamelCaseFieldNamer ¶
type LowerCamelCaseFieldNamer struct {
// contains filtered or unexported fields
}
LowerCamelCaseFieldNamer
func (LowerCamelCaseFieldNamer) GetJSONFieldName ¶
func (lccfn LowerCamelCaseFieldNamer) GetJSONFieldName(t reflect.Type, f reflect.StructField) string
func (LowerCamelCaseFieldNamer) GetTagName ¶
func (lccfn LowerCamelCaseFieldNamer) GetTagName() string
func (LowerCamelCaseFieldNamer) GetTagValue ¶
func (lccfn LowerCamelCaseFieldNamer) GetTagValue(f reflect.StructField) string
type SnakeCaseFieldNamer ¶
type SnakeCaseFieldNamer struct {
// contains filtered or unexported fields
}
SnakeCaseFieldNamer implements CamelCase to snake_case conversion for fields names.
func (SnakeCaseFieldNamer) GetJSONFieldName ¶
func (scfn SnakeCaseFieldNamer) GetJSONFieldName(t reflect.Type, f reflect.StructField) string
func (SnakeCaseFieldNamer) GetTagName ¶
func (scfn SnakeCaseFieldNamer) GetTagName() string
func (SnakeCaseFieldNamer) GetTagValue ¶
func (scfn SnakeCaseFieldNamer) GetTagValue(f reflect.StructField) string