summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-08-10 15:05:54 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-08-10 15:05:54 +0200
commit67100809b399b60e58490fa8b1c0a72be75ac820 (patch)
treeae6df939bf9fe557a766120bee3363f89b47f961 /vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
parent[feature + performance] add JSON logging format (#4355) (diff)
downloadgotosocial-67100809b399b60e58490fa8b1c0a72be75ac820.tar.xz
[chore] update dependencies (#4361)
- codeberg.org/gruf/go-kv/v2 v2.0.5 => v2.0.6 - github.com/coreos/go-oidc/v3 v3.14.1 => v3.15.0 - github.com/miekg/dns v1.1.67 => v1.1.68 - github.com/tdewolff/minify/v2 v2.23.9 => v2.23.11 - github.com/yuin/goldmark v1.7.12 => v1.7.13 - golang.org/x/crypto v0.40.0 => v0.41.0 - golang.org/x/image v0.29.0 => v0.30.0 - golang.org/x/net v0.42.0 => v0.43.0 - golang.org/x/sys v0.34.0 => v0.35.0 - golang.org/x/text v0.27.0 => v0.28.0 - modernc.org/sqlite v1.38.0 => v1.38.2 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4361 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-kv/v2/format/struct.go')
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/struct.go34
1 files changed, 18 insertions, 16 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go b/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
index cc1c8634d..617f65d81 100644
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
+++ b/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
@@ -1,5 +1,7 @@
package format
+import "codeberg.org/gruf/go-xunsafe"
+
// field stores the minimum necessary
// data for iterating and formatting
// each field in a given struct.
@@ -10,23 +12,23 @@ type field struct {
}
// iterStructType returns a FormatFunc capable of iterating
-// and formatting the given struct type currently in typenode{}.
+// and formatting the given struct type currently in TypeIter{}.
// note this will fetch sub-FormatFuncs for each struct field.
-func (fmt *Formatter) iterStructType(t typenode) FormatFunc {
+func (fmt *Formatter) iterStructType(t xunsafe.TypeIter) FormatFunc {
// Number of struct fields.
- n := t.rtype.NumField()
+ n := t.Type.NumField()
// Gather format functions.
fields := make([]field, n)
for i := 0; i < n; i++ {
// Get struct field at index.
- sfield := t.rtype.Field(i)
+ sfield := t.Type.Field(i)
rtype := sfield.Type
- // Get nested field typenode with appropriate flags.
- flags := reflect_struct_field_flags(t.flags, rtype)
- ft := t.next(sfield.Type, flags)
+ // Get nested field TypeIter with appropriate flags.
+ flags := xunsafe.ReflectStructFieldFlags(t.Flag, rtype)
+ ft := t.Child(sfield.Type, flags)
// Get field format func.
fn := fmt.loadOrGet(ft)
@@ -53,8 +55,8 @@ func (fmt *Formatter) iterStructType(t typenode) FormatFunc {
}
}
-func emptyStructType(t typenode) FormatFunc {
- if !t.needs_typestr() {
+func emptyStructType(t xunsafe.TypeIter) FormatFunc {
+ if !needs_typestr(t) {
return func(s *State) {
// Append empty object.
s.B = append(s.B, "{}"...)
@@ -62,7 +64,7 @@ func emptyStructType(t typenode) FormatFunc {
}
// Struct type string with refs.
- typestr := t.typestr_with_refs()
+ typestr := typestr_with_refs(t)
// Append empty object
// with type information.
@@ -74,12 +76,12 @@ func emptyStructType(t typenode) FormatFunc {
}
}
-func iterSingleFieldStructType(t typenode, field field) FormatFunc {
+func iterSingleFieldStructType(t xunsafe.TypeIter, field field) FormatFunc {
if field.format == nil {
panic("nil func")
}
- if !t.needs_typestr() {
+ if !needs_typestr(t) {
return func(s *State) {
// Wrap 'fn' with braces + field name.
s.B = append(s.B, "{"+field.name+"="...)
@@ -89,7 +91,7 @@ func iterSingleFieldStructType(t typenode, field field) FormatFunc {
}
// Struct type string with refs.
- typestr := t.typestr_with_refs()
+ typestr := typestr_with_refs(t)
return func(s *State) {
// Include type info.
@@ -104,14 +106,14 @@ func iterSingleFieldStructType(t typenode, field field) FormatFunc {
}
}
-func iterMultiFieldStructType(t typenode, fields []field) FormatFunc {
+func iterMultiFieldStructType(t xunsafe.TypeIter, fields []field) FormatFunc {
for _, field := range fields {
if field.format == nil {
panic("nil func")
}
}
- if !t.needs_typestr() {
+ if !needs_typestr(t) {
return func(s *State) {
ptr := s.P
@@ -139,7 +141,7 @@ func iterMultiFieldStructType(t typenode, fields []field) FormatFunc {
}
// Struct type string with refs.
- typestr := t.typestr_with_refs()
+ typestr := typestr_with_refs(t)
return func(s *State) {
ptr := s.P