diff --git a/go.mod b/go.mod index fae1d2cba..0959251a5 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( codeberg.org/gruf/go-sched v1.2.4 codeberg.org/gruf/go-split v1.2.0 codeberg.org/gruf/go-storage v0.3.1 - codeberg.org/gruf/go-structr v0.9.8 + codeberg.org/gruf/go-structr v0.9.9 github.com/DmitriyVTitov/size v1.5.0 github.com/KimMachineGun/automemlimit v0.7.4 github.com/SherClockHolmes/webpush-go v1.4.0 diff --git a/go.sum b/go.sum index 83da1a9ff..fdd58eeff 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ codeberg.org/gruf/go-split v1.2.0 h1:PmzL23nVEVHm8VxjsJmv4m4wGQz2bGgQw52dgSSj65c codeberg.org/gruf/go-split v1.2.0/go.mod h1:0rejWJpqvOoFAd7nwm5tIXYKaAqjtFGOXmTqQV+VO38= codeberg.org/gruf/go-storage v0.3.1 h1:g66UIM/xXnEk9ejT+W0T9s/PODBZhXa/8ajzeY/MELI= codeberg.org/gruf/go-storage v0.3.1/go.mod h1:r43n/zi7YGOCl2iSl7AMI27D1zcWS65Bi2+5xDzypeo= -codeberg.org/gruf/go-structr v0.9.8 h1:IouxZ+HPJznegpBmqsJmTu+7ZURwUbnwby/VO6PMaAs= -codeberg.org/gruf/go-structr v0.9.8/go.mod h1:5dsazOsIeJyV8Dl2DdSXqCDEZUx3e3dc41N6f2mPtgw= +codeberg.org/gruf/go-structr v0.9.9 h1:fwIzi/94yBNSWleXZIfVW/QyNK5+/xxI2reVYzu5V/c= +codeberg.org/gruf/go-structr v0.9.9/go.mod h1:5dsazOsIeJyV8Dl2DdSXqCDEZUx3e3dc41N6f2mPtgw= codeberg.org/gruf/go-xunsafe v0.0.0-20250809104800-512a9df57d73 h1:pRaOwIOS1WSZoPCAvE0H1zpv+D4gF37OVppybffqdI8= codeberg.org/gruf/go-xunsafe v0.0.0-20250809104800-512a9df57d73/go.mod h1:9wkq+dmHjUhB/0ZxDUWAwsWuXwwGyx5N1dDCB9hpWs8= codeberg.org/superseriousbusiness/go-swagger v0.32.3-gts-go1.23-fix h1:k76/Th+bruqU/d+dB0Ru466ctTF2aVjKpisy/471ILE= diff --git a/vendor/codeberg.org/gruf/go-structr/README.md b/vendor/codeberg.org/gruf/go-structr/README.md index 922dc1a58..2ea88faef 100644 --- a/vendor/codeberg.org/gruf/go-structr/README.md +++ b/vendor/codeberg.org/gruf/go-structr/README.md @@ -2,7 +2,7 @@ A library with a series of performant data types with automated struct value indexing. Indexing is supported via arbitrary combinations of fields, and in the case of the cache type, negative results (errors!) are also supported. -Under the hood, go-structr maintains a hashmap per index, where each hashmap is a hashmap keyed by serialized input key type. This is handled by the incredibly performant serialization library [go-mangler/v2](https://codeberg.org/gruf/go-mangler), which at this point in time supports *most* arbitrary types (other than channels, functions), so feel free to index by by almost *anything*! +Under the hood, go-structr maintains a hashmap per index, where each hashmap is keyed by serialized input key. This is handled by the incredibly performant serialization library [go-mangler/v2](https://codeberg.org/gruf/go-mangler), which at this point in time supports all concrete types, so feel free to index by by *almost* anything! See the [docs](https://pkg.go.dev/codeberg.org/gruf/go-structr) for more API information. diff --git a/vendor/codeberg.org/gruf/go-structr/index.go b/vendor/codeberg.org/gruf/go-structr/index.go index 9fbdcf112..d5bd5562e 100644 --- a/vendor/codeberg.org/gruf/go-structr/index.go +++ b/vendor/codeberg.org/gruf/go-structr/index.go @@ -21,12 +21,9 @@ type IndexConfig struct { // be specified using periods. An example: // "Username,Favorites.Color" // - // Note that nested fields where the nested - // struct field is a ptr are supported, but - // nil ptr values in nesting will result in - // that particular value NOT being indexed. - // e.g. with "Favorites.Color" if *Favorites - // is nil then it will not be indexed. + // If a nested field encounters a nil pointer + // along the way, e.g. "Favourites == nil", then + // a zero value for "Favorites.Color" is used. // // Field types supported include any of those // supported by the `go-mangler/v2` library. diff --git a/vendor/codeberg.org/gruf/go-structr/runtime.go b/vendor/codeberg.org/gruf/go-structr/runtime.go index c1a883462..8a8d53ede 100644 --- a/vendor/codeberg.org/gruf/go-structr/runtime.go +++ b/vendor/codeberg.org/gruf/go-structr/runtime.go @@ -18,7 +18,8 @@ import ( // including memory offset and hash function. type struct_field struct { - // mangle ... + // struct field type mangling + // (i.e. fast serializing) fn. mangle mangler.Mangler // zero value data, used when @@ -81,6 +82,10 @@ func find_field(t xunsafe.TypeIter, names []string) (sfield struct_field, ftype field reflect.StructField ) + // Take reference + // of parent iter. + o := t + for len(names) > 0 { // Pop next name. name := pop_name() @@ -140,23 +145,41 @@ func find_field(t xunsafe.TypeIter, names []string) (sfield struct_field, ftype // Get mangler from type info. sfield.mangle = mangler.Get(t) - // Get field type as zero interface. - v := reflect.New(t.Type).Elem() - vi := v.Interface() - - // Get argument mangler from iface. - ti := xunsafe.TypeIterFrom(vi) - mangleArg := mangler.Get(ti) - // Calculate zero value string. - zptr := xunsafe.UnpackEface(vi) - zstr := string(mangleArg(nil, zptr)) + zptr := zero_value_field(o, sfield.offsets) + zstr := string(sfield.mangle(nil, zptr)) sfield.zerostr = zstr sfield.zero = zptr return } +// zero_value ... +func zero_value(t xunsafe.TypeIter, offsets []next_offset) reflect.Value { + v := reflect.New(t.Type).Elem() + for _, offset := range offsets { + for range offset.derefs { + if v.IsNil() { + new := reflect.New(v.Type().Elem()) + v.Set(new) + } + v = v.Elem() + } + for i := 0; i < v.NumField(); i++ { + if v.Type().Field(i).Offset == offset.offset { + v = v.Field(i) + break + } + } + } + return v +} + +// zero_value_field ... +func zero_value_field(t xunsafe.TypeIter, offsets []next_offset) unsafe.Pointer { + return zero_value(t, offsets).Addr().UnsafePointer() +} + // extract_fields extracts given structfields from the provided value type, // this is done using predetermined struct field memory offset locations. func extract_fields(ptr unsafe.Pointer, fields []struct_field) []unsafe.Pointer { diff --git a/vendor/modules.txt b/vendor/modules.txt index 20a6b48e7..e082e4ec1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -293,7 +293,7 @@ codeberg.org/gruf/go-storage/disk codeberg.org/gruf/go-storage/internal codeberg.org/gruf/go-storage/memory codeberg.org/gruf/go-storage/s3 -# codeberg.org/gruf/go-structr v0.9.8 +# codeberg.org/gruf/go-structr v0.9.9 ## explicit; go 1.24.5 codeberg.org/gruf/go-structr # codeberg.org/gruf/go-xunsafe v0.0.0-20250809104800-512a9df57d73