Skip to content

Commit

Permalink
use build tags
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobOaks committed Jul 1, 2024
1 parent ec57966 commit d0d7a32
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions errcheck/embedded_walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func walkThroughEmbeddedInterfaces(sel *types.Selection) ([]types.Type, bool) {
}

func getTypeAtFieldIndex(startingAt types.Type, fieldIndex int) types.Type {
t := maybeDereference(types.Unalias(startingAt))
t = maybeUnname(types.Unalias(t))
t := maybeDereference(maybeUnalias(startingAt))
t = maybeUnname(maybeUnalias(t))
s, ok := t.(*types.Struct)
if !ok {
panic(fmt.Sprintf("cannot get Field of a type that is not a struct, got a %T", t))
Expand Down
10 changes: 10 additions & 0 deletions errcheck/embedded_walker_121.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !go1.22
// +build !go1.22

package errcheck

import "go/types"

func maybeUnalias(t types.Type) types.Type {
return t
}
10 changes: 10 additions & 0 deletions errcheck/embedded_walker_122.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build go1.22
// +build go1.22

package errcheck

import "go/types"

func maybeUnalias(t types.Type) types.Type {
return types.Unalias(t)
}

0 comments on commit d0d7a32

Please sign in to comment.