Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -750,6 +750,11 @@ func normaliseValue(v reflect.Value) (any, error) {
|
||||
if v.Type() == durationType {
|
||||
return time.Duration(v.Int()).String(), nil
|
||||
}
|
||||
// A Number goes out as the literal it carries, the one string-kind value
|
||||
// that is not written quoted.
|
||||
if v.Type() == numberType {
|
||||
return Number(v.String()), nil
|
||||
}
|
||||
// A type that renders itself as text becomes a TOML string, scalar kinds
|
||||
// and structs alike.
|
||||
s, isText, err := textValue(v)
|
||||
@@ -1171,6 +1176,12 @@ func (e *encoder) writeValue(val any) error {
|
||||
case int64:
|
||||
e.buf.WriteString(strconv.FormatInt(v, 10))
|
||||
return nil
|
||||
case Number:
|
||||
if _, err := decodeNumber(string(v)); err != nil {
|
||||
return fmt.Errorf("interpres: %w", err)
|
||||
}
|
||||
e.buf.WriteString(string(v))
|
||||
return nil
|
||||
case float64:
|
||||
return e.writeFloat(v)
|
||||
case time.Time:
|
||||
|
||||
Reference in New Issue
Block a user