Skip to content

Commit

Permalink
Initial fix for underlying struct mis-match bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilken Rivera committed Oct 19, 2023
1 parent 2fc2ffd commit a93cfdb
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,17 @@ func (cmd *Command) Run(args []string) int {
if !utOk {
continue
}

pos := sort.SearchStrings(typeNames, id.Name)
if pos >= len(typeNames) || typeNames[pos] != id.Name {
continue // not a struct we care about
}
// Sometimes we see the underlying struct for a similar name typed, which results
// in an incorrect FlatMap. If the type names are not exactly the same skip.
if nt.Obj().Name() != id.Name {
continue // not the struct we are looking for
}

// make sure each type is found once where somehow sometimes they can be found twice
typeNames = append(typeNames[:pos], typeNames[pos+1:]...)
flatenedStruct, err := getMapstructureSquashedStruct(obj.Pkg(), utStruct)
Expand Down

0 comments on commit a93cfdb

Please sign in to comment.