-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
As of v0.7.0 formatting is configurable at the struct field level.
type Record struct {
Field1 string `fixed:"1,5,left,#"`
Field2 string `fixed:"6,10,left,#"`
Field3 string `fixed:"11,15,left,#"`
Field4 string `fixed:"16,20,left,#"`
...
}Adding all of the required tags can be tedious when all of the fields require a specific format. To alleviate this, there should be a mechanism to set the default format for all the fields in a struct.
My current thought is to implement something similar to xml.Name.
type Record struct {
// Format is a special struct that can be embedded into a struct to control
// the default formatting of its fields.
fixedwidth.Format `fixed:"left,#"`
Field1 string `fixed:"1,5"`
Field2 string `fixed:"6,10"`
Field3 string `fixed:"11,15"`
Field4 string `fixed:"16,20,right,0"` // Override the default formatting.
...
}Reactions are currently unavailable