Skip to content

Conversation

@cmilesdev
Copy link
Member

Changes

  • Adjusted max‑depth behavior to truncate only complex container types at the depth boundary while still printing scalar fields.
  • Fixed Stringer/max‑depth interaction so Stringers no longer bypass depth limits, and nil values render consistently.
  • Expanded max‑depth test coverage across maps, slices, arrays, pointers, interfaces, and nil containers.

Addresses #45

@codecov
Copy link

codecov bot commented Dec 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines 962 to 1240
func isComplexValue(v reflect.Value) bool {
_, ok := complexBaseKind(v)
return ok
}

func complexBaseKind(v reflect.Value) (reflect.Kind, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if quite no one use complex integers in Go it's a thing. So here, I feel like the wording could be different.

But I don't have better wording that "complicated" but it may sound strange too

@Akkadius Akkadius force-pushed the cmilesdev/depth-issue-fix branch from 1189729 to 07935f2 Compare December 24, 2025 00:16
@cmilesdev cmilesdev merged commit 306734d into main Dec 24, 2025
7 checks passed
Comment on lines +1252 to +1272
for {
switch v.Kind() {
case reflect.Interface:
if v.IsNil() {
return 0, false
}
v = v.Elem()
case reflect.Ptr:
if v.IsNil() {
return 0, false
}
v = v.Elem()
default:
switch v.Kind() {
case reflect.Struct, reflect.Map, reflect.Slice, reflect.Array:
return v.Kind(), true
default:
return 0, false
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to do not do this ?

Suggested change
for {
switch v.Kind() {
case reflect.Interface:
if v.IsNil() {
return 0, false
}
v = v.Elem()
case reflect.Ptr:
if v.IsNil() {
return 0, false
}
v = v.Elem()
default:
switch v.Kind() {
case reflect.Struct, reflect.Map, reflect.Slice, reflect.Array:
return v.Kind(), true
default:
return 0, false
}
}
}
for {
switch v.Kind() {
case reflect.Interface:
if v.IsNil() {
return 0, false
}
v = v.Elem()
case reflect.Ptr:
if v.IsNil() {
return 0, false
}
v = v.Elem()
case reflect.Struct, reflect.Map, reflect.Slice, reflect.Array:
return v.Kind(), true
default:
return 0, false
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants