updated dependencies and go

This commit is contained in:
2026-04-21 11:06:01 +02:00
parent f62e7499ec
commit 84b87d61f2
91 changed files with 551 additions and 637 deletions
+5 -13
View File
@@ -177,7 +177,7 @@ type IndentOpt struct {
// MarshalSafeCollections is like Marshal except it will marshal nil maps and
// slices as '{}' and '[]' respectfully instead of 'null'
func MarshalSafeCollections(v interface{}, nilSafeSlices bool, nilSafeMaps bool, indent *IndentOpt, filter *string) ([]byte, error) {
func MarshalSafeCollections(v any, nilSafeSlices bool, nilSafeMaps bool, indent *IndentOpt, filter *string) ([]byte, error) {
e := &encodeState{}
err := e.marshal(v, encOpts{escapeHTML: true, nilSafeSlices: nilSafeSlices, nilSafeMaps: nilSafeMaps, filter: filter})
if err != nil {
@@ -891,7 +891,7 @@ func (se sliceEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {
// Here we use a struct to memorize the pointer to the first element of the slice
// and its length.
ptr := struct {
ptr interface{} // always an unsafe.Pointer, but avoids a dependency on package unsafe
ptr any // always an unsafe.Pointer, but avoids a dependency on package unsafe
len int
}{v.UnsafePointer(), v.Len()}
if _, ok := e.ptrSeen[ptr]; ok {
@@ -923,7 +923,7 @@ type arrayEncoder struct {
func (ae arrayEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {
e.WriteByte('[')
n := v.Len()
for i := 0; i < n; i++ {
for i := range n {
if i > 0 {
e.WriteByte(',')
}
@@ -1075,10 +1075,7 @@ func appendString[Bytes []byte | string](dst []byte, src Bytes, escapeHTML bool)
// For now, cast only a small portion of byte slices to a string
// so that it can be stack allocated. This slows down []byte slightly
// due to the extra copy, but keeps string performance roughly the same.
n := len(src) - i
if n > utf8.UTFMax {
n = utf8.UTFMax
}
n := min(len(src)-i, utf8.UTFMax)
c, size := utf8.DecodeRuneInString(string(src[i : i+n]))
if c == utf8.RuneError && size == 1 {
dst = append(dst, src[start:i]...)
@@ -1130,12 +1127,7 @@ type field struct {
type jsonfilter []string
func (j jsonfilter) Contains(t string) bool {
for _, tag := range j {
if t == tag {
return true
}
}
return false
return slices.Contains(j, t)
}
// typeFields returns a list of fields that JSON should recognize for the given type.