Skip to content

Commit

Permalink
Add alignment none
Browse files Browse the repository at this point in the history
Add `noAlignment` const that indicates no trimming should occur during
decoding.
  • Loading branch information
ianlopshire committed Feb 8, 2024
1 parent 48332ed commit 45d0d87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ func rawValueFromLine(value rawValue, startPos, endPos int, format format) rawVa
trimFunc = func(s string) string {
return strings.TrimLeft(s, string(format.padChar))
}
case noAlignment:
trimFunc = func(s string) string { return s }
default:
trimFunc = func(s string) string {
return strings.Trim(s, string(format.padChar))
Expand Down
3 changes: 2 additions & 1 deletion format.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fixedwidth

const (
defaultAlignment alignment = "default"
noAlignment alignment = "none"
right alignment = "right"
left alignment = "left"
)
Expand All @@ -24,7 +25,7 @@ type alignment string

func (a alignment) Valid() bool {
switch a {
case defaultAlignment, right, left:
case defaultAlignment, right, left, noAlignment:
return true
default:
return false
Expand Down

0 comments on commit 45d0d87

Please sign in to comment.