Move separator defaulting back into Tag.
This commit is contained in:
@@ -234,9 +234,6 @@ func mapDecoder(d *Registry) MapperFunc {
|
||||
}
|
||||
el := target.Type()
|
||||
sep := ctx.Value.Tag.Sep
|
||||
if sep == 0 {
|
||||
sep = '='
|
||||
}
|
||||
token := ctx.Scan.PopValue("map")
|
||||
parts := SplitEscaped(token, sep)
|
||||
if len(parts) != 2 {
|
||||
@@ -267,9 +264,6 @@ func sliceDecoder(d *Registry) MapperFunc {
|
||||
return func(ctx *DecodeContext, target reflect.Value) error {
|
||||
el := target.Type().Elem()
|
||||
sep := ctx.Value.Tag.Sep
|
||||
if sep == 0 {
|
||||
sep = ','
|
||||
}
|
||||
var childScanner *Scanner
|
||||
if ctx.Value.Flag != nil {
|
||||
// If decoding a flag, we need an argument.
|
||||
|
||||
@@ -27,9 +27,6 @@ func JSON(r io.Reader) (ResolverFunc, error) {
|
||||
return "", nil
|
||||
}
|
||||
sep := flag.Tag.Sep
|
||||
if sep == 0 {
|
||||
sep = ','
|
||||
}
|
||||
value, err := jsonDecodeValue(sep, raw)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -130,6 +130,13 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag {
|
||||
t.Hidden = t.Has("hidden")
|
||||
t.Format, _ = t.Get("format")
|
||||
t.Sep, _ = t.GetRune("sep")
|
||||
if t.Sep == 0 {
|
||||
if fv.Kind() == reflect.Map {
|
||||
t.Sep = '='
|
||||
} else {
|
||||
t.Sep = ','
|
||||
}
|
||||
}
|
||||
t.PlaceHolder, _ = t.Get("placeholder")
|
||||
if t.PlaceHolder == "" {
|
||||
t.PlaceHolder = strings.ToUpper(dashedString(fv.Type().Name()))
|
||||
|
||||
Reference in New Issue
Block a user