diff options
author | 2025-02-13 08:53:40 +0000 | |
---|---|---|
committer | 2025-02-13 09:53:40 +0100 | |
commit | 24f6760c0e355903458f71e539201c8bf37cfac6 (patch) | |
tree | c5f43e72ba452fddceb3c2531a64d4b835246927 /vendor/github.com/ncruces/go-sqlite3/internal/util/json.go | |
parent | [feature] Implement backfilling statuses thru scheduled_at (#3685) (diff) | |
download | gotosocial-24f6760c0e355903458f71e539201c8bf37cfac6.tar.xz |
[chore] bump ncruces go-sqlite3 => v0.23.0 (#3785)
* bump ncruces go-sqlite3 => v0.23.0
* whoops, add missing vendor changes...
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/internal/util/json.go')
-rw-r--r-- | vendor/github.com/ncruces/go-sqlite3/internal/util/json.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/internal/util/json.go b/vendor/github.com/ncruces/go-sqlite3/internal/util/json.go index 7f6849a42..846237405 100644 --- a/vendor/github.com/ncruces/go-sqlite3/internal/util/json.go +++ b/vendor/github.com/ncruces/go-sqlite3/internal/util/json.go @@ -2,6 +2,7 @@ package util import ( "encoding/json" + "math" "strconv" "time" "unsafe" @@ -20,7 +21,7 @@ func (j JSON) Scan(value any) error { case int64: buf = strconv.AppendInt(nil, v, 10) case float64: - buf = strconv.AppendFloat(nil, v, 'g', -1, 64) + buf = AppendNumber(nil, v) case time.Time: buf = append(buf, '"') buf = v.AppendFormat(buf, time.RFC3339Nano) @@ -33,3 +34,17 @@ func (j JSON) Scan(value any) error { return json.Unmarshal(buf, j.Value) } + +func AppendNumber(dst []byte, f float64) []byte { + switch { + case math.IsNaN(f): + dst = append(dst, "null"...) + case math.IsInf(f, 1): + dst = append(dst, "9.0e999"...) + case math.IsInf(f, -1): + dst = append(dst, "-9.0e999"...) + default: + return strconv.AppendFloat(dst, f, 'g', -1, 64) + } + return dst +} |