From e96b1ef99bdd18a6f777892008f614a4401d6655 Mon Sep 17 00:00:00 2001 From: Konstantin Shaposhnikov Date: Mon, 27 Jun 2016 13:37:01 +0800 Subject: [PATCH] cmd/vet: fix name check for examples in _test package This fixes the obvious bug and makes go vet look for identifiers in foo package when checking example names in foo_test package. Note that for this check to work the foo package have to be installed (using go install). This commit however doesn't fix TestDivergentPackagesExamples test that is not implemented correctly and passes only by chance. Updates #16189 Change-Id: I5c2f675cd07e5b66cf0432b2b3e422ab45c3dedd Reviewed-on: https://go-review.googlesource.com/24487 Reviewed-by: Dmitri Shuralyov Run-TryBot: Rob Pike TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- src/cmd/vet/tests.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/vet/tests.go b/src/cmd/vet/tests.go index 52ad334098..076835b980 100644 --- a/src/cmd/vet/tests.go +++ b/src/cmd/vet/tests.go @@ -63,7 +63,7 @@ func extendedScope(pkg *Package) []*types.Scope { scopes := []*types.Scope{pkg.typesPkg.Scope()} pkgName := pkg.typesPkg.Name() - if strings.HasPrefix(pkgName, "_test") { + if strings.HasSuffix(pkgName, "_test") { basePkg := strings.TrimSuffix(pkgName, "_test") for _, p := range pkg.typesPkg.Imports() { if p.Name() == basePkg { -- 2.48.1