Documentation
¶
Index ¶
Constants ¶
View Source
const ( // EOLUnix represents Unix/Linux style end of line. EOLUnix = "\n" // EOLMac represents Macintosh style end of line. EOLMac = "\r" // EOLDOS represents DOS/Windows style end of line. EOLDOS = "\r\n" )
Variables ¶
View Source
var DecimalComma bool
DecimalComma enables the parsing of numeric values having a comma instead of a point as decimal separator.
Functions ¶
func RecordsFromFile ¶
RecordsFromFile reads a file and splits into single line records, which can be unmarshalled.
func Unmarshal ¶
Unmarshal unmarshals string data into an annotated interface. This should resemble:
type SomeType struct {
ValA string `fixed:"1-5"`
ValB int `fixed:"10-15"`
ValC *EmbeddedType `fixed:"16-22"`
}
type EmbeddedType struct {
ValX string `fixed:"1-3"`
ValY string `fixed:"4-6"`
ValZ string `fixed:"8"`
}
var out SomeType
err := Unmarshal("some string here", &out)
String offsets are one based, not zero based.
func UnmarshalCsv ¶
UnmarshalCsv unmarshals string data into an annotated interface. This should resemble:
type SomeType struct {
ValA string `csv:"1"`
ValB int `csv:"2"`
ValC *EmbeddedType `csv:"3" csvsplit:"~"`
WholeLine string `csv:"raw"`
}
type EmbeddedType struct {
ValX string `csv:"1"`
ValY string `csv:"2"`
}
var out SomeType
err := Unmarshal("A,2,X~Y", ",", &out)
String offsets are one based, not zero based.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.

