Documentation
¶
Overview ¶
Package genjay 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 MethodMarshalJ = "MarshalJ" MethodUnmarshalJ = "UnmarshalJ" 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 vary in length (8-bit to 64-bit) or be a fixed length (32-bit, or 64-bit) depending on the system's architecture.
// True = Least bandwidth used.
// False = Fastest CPU serialization/deserialization throughput.
VariableUintSize bool
Verbose *log.Logger
SearchTests bool // When true, searches Go test files for exported structs too.
// IsMarshalMethodPtr changes generated MarshalJ method to a pointer receiver. Used for suppressing Go linter messages:
// `Struct ... has methods on both value and pointer receivers. Such usage is not recommended by the Go Documentation.`
// True: `func (f *Foo) MarshalJ()`,
// False: `func (f Foo) MarshalJ()`.
IsMarshalMethodPtr bool
SkipTests bool
SkipMarshal bool // When true doesn't generate any marshalling methods.
SkipUnmarshal bool // When true doesn't generate any unmarshalling methods.
// contains filtered or unexported fields
}
func LoadOptions ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.