Documentation
¶
Overview ¶
Package generate scans .go files for exported structs and generates methods .MarshalJ() and .UnmarshalJ() to serialize structs into the Jay serialization format https://github.com/speedyhoon/jay.
Index ¶
Constants ¶
View Source
const ( TagIgnore structTag = iota - 2 TagEmbed TagNone DecIgnore = "J--" DecEmbed = "J-" )
View Source
const ( ExportedErr = pkgName + ".ErrUnexpectedEOB" DefaultOutputFileName = pkgName + ext.Go IntSize = 32 << (^uint(0) >> 63) // 32-bit or 64-bit architecture. )
View Source
const ( BitAuto = MaxSize(iota * 32) Bit32 Bit64 )
View Source
const ( StructTagName = "j" // StructTagName is the field tag to specify optional flags. For example, `j:max=0` IgnoreFlag = "-" // IgnoreFlag is the value to ignore any exported field from serializing: `j:-` )
Variables ¶
View Source
var ( ErrNoSource = errors.New("no filename or source provided") ErrNoneExported = errors.New("no exported struct fields found") )
Functions ¶
func IsCommentOrWhitespace ¶
Types ¶
type Option ¶
type Option struct {
// ErrVarName is the name of an exported error variable to return from UnmarshalJ functions,
// overriding the default "jay.ErrUnexpectedEOB". Helpful if generated code imports the jay package only for the error variable.
ErrVarName string
MaxIntSize MaxSize
MaxUintSize MaxSize
Is32bit bool
IsDebug bool
// MaxDefaultStrSize limits all strings to be within this length if a field tag is NOT present.
// Minimum: 1 (1 byte),
// Default: maxUint8 (255 bytes),
// Maximum: maxUint24 (16 Megabytes).
// To override the default for a field use: `j:"max:4030"` for 4,030 bytes.
// The smallest value is the most optimal for performance.
MaxDefaultStrSize uint
// OnlyTypes will only generate marshalling & unmarshalling functions for the listed types.
// When empty, all types are permitted.
// Expected struct type alias names like: "Vehicle", "animal.Species".
OnlyTypes []string
OutputFileName string
// Whether type `int` should be a fixed length (4 bytes for 32-bit, or 8 bytes for 64-bit) or vary in length depending on the value provided.
VariableIntSize bool
// Whether type `uint` should be a fixed length (4 bytes 32-bit, or 8 bytes 64-bit) or vary in length depending on the value provided.
// True = Highest CPU serialization/deserialization throughput,
// false = Least bandwidth used.
VariableUintSize bool
Verbose *log.Logger
SearchTests bool
// IsMarshalMethodPtr changes generated MarshalJ method to a pointer receiver. true: `func (f *Foo) MarshalJ()`, false: `func (f Foo) MarshalJ()`.
IsMarshalMethodPtr bool
SkipTests bool
SkipMarshal bool
SkipUnmarshal bool
// contains filtered or unexported fields
}
func LoadOptions ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.