Fix sep:"none" and mapsep:"none"
According to the README.md, a value of `"none"` for the `sep` tag (for slices) and `mapsep` (for maps) is meant to disable the separator that would allow multiple entries to be added from a single argument. However, using `"none"` just set the separator to the rune `'n'`. Fix the parsing of the tag, and also update `SplitEscaped` to not split with a separator of `-1`. Add a new test for the new cases.
This commit is contained in:
committed by
Alec Thomas
parent
b11ebc500b
commit
b89354adb0
@@ -151,23 +151,23 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag {
|
||||
t.Short, _ = t.GetRune("short")
|
||||
t.Hidden = t.Has("hidden")
|
||||
t.Format = t.Get("format")
|
||||
t.Sep, _ = t.GetRune("sep")
|
||||
t.MapSep, _ = t.GetRune("mapsep")
|
||||
t.Group = t.Get("group")
|
||||
t.Xor = t.Get("xor")
|
||||
t.Prefix = t.Get("prefix")
|
||||
t.Embed = t.Has("embed")
|
||||
if t.Sep == 0 {
|
||||
if t.Get("sep") == "none" {
|
||||
t.Sep = -1
|
||||
} else {
|
||||
if t.Get("sep") == "none" {
|
||||
t.Sep = -1
|
||||
} else {
|
||||
t.Sep, _ = t.GetRune("sep")
|
||||
if t.Sep == 0 {
|
||||
t.Sep = ','
|
||||
}
|
||||
}
|
||||
if t.MapSep == 0 {
|
||||
if t.Get("mapsep") == "none" {
|
||||
t.MapSep = -1
|
||||
} else {
|
||||
if t.Get("mapsep") == "none" {
|
||||
t.MapSep = -1
|
||||
} else {
|
||||
t.MapSep, _ = t.GetRune("mapsep")
|
||||
if t.MapSep == 0 {
|
||||
t.MapSep = ';'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user