Documentation
¶
Index ¶
- func AdjustTypes(file *ast.File, registeredTypeCheckers []TypeDeterminationFunction, ...) error
- func CombineStructsOfFile(file, file1 *ast.File) (*ast.File, error)
- func GenerateCodeIntoDecl(jsonData []byte, decls []ast.Decl, structName string) ([]ast.Decl, error)
- func GenerateJsonMarshall(file *ast.File) error
- func GenerateJsonUnmarshall(file *ast.File) error
- func SetMixedTypes(tag *ast.BasicLit) (*ast.BasicLit, error)
- type IntTypeChecker
- func (i *IntTypeChecker) CouldTypeBeApplied(seenValues map[string]string) bool
- func (i *IntTypeChecker) GenerateFromTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
- func (i *IntTypeChecker) GenerateToTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
- func (i *IntTypeChecker) GetName() string
- func (i *IntTypeChecker) GetRequiredImports() []string
- func (i *IntTypeChecker) GetType() ast.Expr
- func (i *IntTypeChecker) SetFile(_ *ast.File)
- type ParseFunctions
- type Tag
- type TagCombiner
- type TimeTypeChecker
- func (t *TimeTypeChecker) CouldTypeBeApplied(seenValues map[string]string) bool
- func (t *TimeTypeChecker) GenerateFromTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
- func (t *TimeTypeChecker) GenerateToTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
- func (t *TimeTypeChecker) GetName() string
- func (t *TimeTypeChecker) GetRequiredImports() []string
- func (t *TimeTypeChecker) GetType() ast.Expr
- func (t *TimeTypeChecker) SetFile(_ *ast.File)
- type TypeDeterminationFunction
- type UUIDTypeChecker
- func (u *UUIDTypeChecker) CouldTypeBeApplied(seenValues map[string]string) bool
- func (u *UUIDTypeChecker) GenerateFromTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
- func (u *UUIDTypeChecker) GenerateToTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
- func (u *UUIDTypeChecker) GetName() string
- func (u *UUIDTypeChecker) GetRequiredImports() []string
- func (u *UUIDTypeChecker) GetType() ast.Expr
- func (u *UUIDTypeChecker) SetFile(_ *ast.File)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustTypes ¶
func AdjustTypes(file *ast.File, registeredTypeCheckers []TypeDeterminationFunction, skipPreviouslyFailed bool) error
AdjustTypes Goes through all fields and looks at the json2go Tag, to determine if there's a better suiting type for the seen float and string values. Floats which could be represented as an int, are changed to int Strings which could be represented as UUID are change into uuid.UUID Strings which could be represented as time, are changed into time.Time
func GenerateCodeIntoDecl ¶
func GenerateJsonMarshall ¶
func GenerateJsonUnmarshall ¶
Types ¶
type IntTypeChecker ¶
type IntTypeChecker struct{}
func (*IntTypeChecker) CouldTypeBeApplied ¶
func (i *IntTypeChecker) CouldTypeBeApplied(seenValues map[string]string) bool
func (*IntTypeChecker) GenerateFromTypeFunction ¶
func (*IntTypeChecker) GenerateToTypeFunction ¶
func (*IntTypeChecker) GetName ¶
func (i *IntTypeChecker) GetName() string
func (*IntTypeChecker) GetRequiredImports ¶
func (i *IntTypeChecker) GetRequiredImports() []string
func (*IntTypeChecker) GetType ¶
func (i *IntTypeChecker) GetType() ast.Expr
func (*IntTypeChecker) SetFile ¶
func (i *IntTypeChecker) SetFile(_ *ast.File)
type ParseFunctions ¶
type Tag ¶
type Tag struct {
// SeenValues Holds all seem field values and their corresponding type
SeenValues map[string]string `json:"seenValues,omitempty"`
// CheckedNonMatchingTypes Is used to store a map of non-matching types referencing the time of storage as unix timestamp.
// This is useful when working with a lot of input data, and the seen values becomes to big
CheckedNonMatchingTypes map[string]int64 `json:"checkedNonMatchingTypes,omitempty"`
// ParseFunctions Holds the names of the parse functions generated by TypeDeterminationFunction
ParseFunctions *ParseFunctions `json:"parseFunctions,omitempty"`
// BaseType The type before it was modified from a TypeDeterminationFunction
BaseType *string `json:"baseType,omitempty"`
// MixedTypes is set, whenever an array whit mixed types is encountered
MixedTypes bool `json:"mixedTypes,omitempty"`
// LastSeenTimestamp Unix timestamp. Is updated whenever a value is seen
LastSeenTimestamp int64 `json:"lastSeenTimestamp"`
}
func GetJson2GoTag ¶
func (*Tag) ToTagString ¶
func (*Tag) ToTagValue ¶
type TagCombiner ¶
type TagCombiner struct{}
type TimeTypeChecker ¶
type TimeTypeChecker struct {
// IgnoreYearOnlyStrings Set to ignore strings that consist only of a year such as 3294. Most often, they're
// integers not years!
IgnoreYearOnlyStrings bool
// contains filtered or unexported fields
}
func (*TimeTypeChecker) CouldTypeBeApplied ¶
func (t *TimeTypeChecker) CouldTypeBeApplied(seenValues map[string]string) bool
func (*TimeTypeChecker) GenerateFromTypeFunction ¶
func (*TimeTypeChecker) GenerateToTypeFunction ¶
func (*TimeTypeChecker) GetName ¶
func (t *TimeTypeChecker) GetName() string
func (*TimeTypeChecker) GetRequiredImports ¶
func (t *TimeTypeChecker) GetRequiredImports() []string
func (*TimeTypeChecker) GetType ¶
func (t *TimeTypeChecker) GetType() ast.Expr
func (*TimeTypeChecker) SetFile ¶
func (t *TimeTypeChecker) SetFile(_ *ast.File)
type TypeDeterminationFunction ¶
type TypeDeterminationFunction interface {
CouldTypeBeApplied(seenValues map[string]string) bool
GetType() ast.Expr
GenerateFromTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
GenerateToTypeFunction(functionScaffold *ast.FuncDecl) (*ast.FuncDecl, error)
GetRequiredImports() []string
SetFile(file *ast.File)
GetName() string
}
type UUIDTypeChecker ¶
type UUIDTypeChecker struct{}
func (*UUIDTypeChecker) CouldTypeBeApplied ¶
func (u *UUIDTypeChecker) CouldTypeBeApplied(seenValues map[string]string) bool
func (*UUIDTypeChecker) GenerateFromTypeFunction ¶
func (*UUIDTypeChecker) GenerateToTypeFunction ¶
func (*UUIDTypeChecker) GetName ¶
func (u *UUIDTypeChecker) GetName() string
func (*UUIDTypeChecker) GetRequiredImports ¶
func (u *UUIDTypeChecker) GetRequiredImports() []string
func (*UUIDTypeChecker) GetType ¶
func (u *UUIDTypeChecker) GetType() ast.Expr
func (*UUIDTypeChecker) SetFile ¶
func (u *UUIDTypeChecker) SetFile(_ *ast.File)
Click to show internal directories.
Click to hide internal directories.