Skip to content

Commit

Permalink
TextUnmarshaler is Excluded from Mangling
Browse files Browse the repository at this point in the history
We shouldn't ever mangle types that implement TextUnmarshaler.
  • Loading branch information
sergiosalvatore committed Aug 29, 2024
1 parent 4f66430 commit dbcdd5f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions transform/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,20 @@ func (t *Transformer) maybeRecursivelyMangle(mangler Mangler, state *transformMa
if !mangler.ShouldRecurse(field) {
continue
}

ft := field.Type

// also don't recurse into TextUnarshaler types
if ft.Implements(textMReflectType) || reflect.PointerTo(ft).Implements(textMReflectType) {
continue
}

// strip any outer pointerification, slice or array
switch ft.Kind() {
case reflect.Ptr, reflect.Array, reflect.Slice:
ft = ft.Elem()
}

fieldTransformer := Transformer{
manglers: []Mangler{mangler},
mState: nil,
Expand Down

0 comments on commit dbcdd5f

Please sign in to comment.