Fix: wrap error
This commit is contained in:
parent
3008d84b9a
commit
d7ff3c3107
|
@ -153,13 +153,14 @@ func handleArray(valueString string) (value any) {
|
|||
if intErr == nil {
|
||||
intVals = append(intVals, avalInt)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(intVals) == len(asplit) && len(intVals) > 0 {
|
||||
value = intVals
|
||||
} else {
|
||||
value = asplit
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
|
@ -276,6 +277,7 @@ func (d *decoder) readData() error {
|
|||
}
|
||||
|
||||
myTable, mapAssertOK := d.tables[string(tableName)].(map[string]interface{})
|
||||
|
||||
if !mapAssertOK {
|
||||
d.tables[string(tableName)] = make(map[string]interface{})
|
||||
myTable = d.tables[string(tableName)].(map[string]interface{}) //nolint:forcetypeassert
|
||||
|
@ -334,7 +336,7 @@ func trimTest(data []byte) (trimmed []byte) {
|
|||
func UnmarshalTOML(data []byte, v interface{}) error {
|
||||
var err error
|
||||
if data, err = unicode.UTF8.NewDecoder().Bytes(data); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unicode decode failure: %w", err)
|
||||
}
|
||||
|
||||
if !bytes.Contains(data, []byte("[")) {
|
||||
|
@ -360,6 +362,7 @@ func UnmarshalTOML(data []byte, v interface{}) error {
|
|||
if ref.Elem().Kind() != reflect.Struct {
|
||||
return fmt.Errorf("%w: non-struct", ErrBadTarget)
|
||||
}
|
||||
|
||||
data = bytes.ReplaceAll(data, []byte("\r"), []byte(""))
|
||||
|
||||
return newDecoder(data, v).start()
|
||||
|
|
|
@ -118,7 +118,7 @@ func handleBottomLevelField(field reflect.StructField, ref reflect.Value, buf *p
|
|||
_, _ = buf.WriteString(field.Tag.Get("toml"))
|
||||
_, _ = buf.WriteString(" = ")
|
||||
//goland:noinspection GoSwitchMissingCasesForIotaConsts
|
||||
switch ref.Kind() {
|
||||
switch ref.Kind() { //nolint:exhaustive
|
||||
case reflect.String:
|
||||
if err := handleString(ref.String(), buf); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue