Add constants for *nil, *space and *char

This commit is contained in:
ionutboangiu
2023-10-06 11:06:39 -04:00
committed by Dan Christian Bogos
parent f0fea43a41
commit 3678c620d6
2 changed files with 6 additions and 3 deletions

View File

@@ -181,6 +181,9 @@ const (
MetaSingle = "*single"
MetaZero = "*zero"
MetaASAP = "*asap"
MetaNil = "*nil"
MetaSpace = "*space"
MetaChar = "*char"
CommentChar = '#'
CSVSep = ','
FallbackSep = ';'

View File

@@ -611,8 +611,8 @@ func NewStripConverter(params string) (DataConverter, error) {
switch sc.substr {
case EmptyString:
return nil, errors.New("strip converter: substr parameter cannot be empty")
case "*nil", "*space":
if sc.substr == "*nil" {
case MetaNil, MetaSpace:
if sc.substr == MetaNil {
sc.substr = "\u0000"
} else {
sc.substr = " "
@@ -624,7 +624,7 @@ func NewStripConverter(params string) (DataConverter, error) {
}
sc.substr = strings.Repeat(sc.substr, sc.amount)
}
case "*char":
case MetaChar:
if len(paramSlice) < 4 {
return nil, errors.New("strip converter: usage of *char implies the need of 4 or 5 params")
}