Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcNumFieldsToUnmarshal ¶
CalcNumFieldsToUnmarshal determines how many fields can be unmarshalled successfully This currently will not return an accurate result for overlapping fields For example:
type Profile struct { FirstName string `flatfile:"1,10"` LastName string `flatfile:"11,10"` FullName string `flatfile:"1,20"` }
Expected output is that 3 fields can be unmarshalled successfully The result will be 2 Another example: type Profile struct
type Profile struct { FirstName string `flatfile:"1,10"` LastName string `flatfile:"11,10"` FullName string `flatfile:"1,20"` Random string `flatfile:"7,9"` }
This function would have to be redesigned to handle multiple scenarios of overlapping fields
func Examine ¶
func Examine(v interface{})
Examine traverses all elements of a type and uses the reflect pkg to print type and kind
func ShouldUnmarshal ¶
ShouldUnmarshal returns true if the condition
func Unmarshal ¶
func Unmarshal(data []byte, v interface{}, startFieldIdx int, numFieldsToUnmarshal int, isPartialUnmarshal bool) error
Unmarshal will read data and convert it into a struct based on a schema/map defined by struct tags
Struct tags are in the form `flatfile:"col,len"`. col and len should be integers > 0
startFieldIdx: index can be passed to indicate which struct field to start the unmarshal. Zero indexed.
numFieldsToUnmarshal: can be passed to indicate how many fields to unmarshal starting from startFieldIdx
isPartialUnmarshal: flag should be set to true if the data[0] is intended to be unmarshalled at startFieldIdx
If startFieldIdx == 0 and umFieldsToMarshal == 0 then Unmarshal will attempt to unmarshal all fields with an ffp tag