From 712de1c63d9db97c81af68cd0dc4372c53d2e57a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 15 Sep 2020 18:05:35 +0200 Subject: vendor/github.com/golangci/golangci-lint: update to v1.31 --- .../gostaticanalysis/analysisutil/pkg.go | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'vendor/github.com/gostaticanalysis/analysisutil/pkg.go') diff --git a/vendor/github.com/gostaticanalysis/analysisutil/pkg.go b/vendor/github.com/gostaticanalysis/analysisutil/pkg.go index c98710d18..b64150d81 100644 --- a/vendor/github.com/gostaticanalysis/analysisutil/pkg.go +++ b/vendor/github.com/gostaticanalysis/analysisutil/pkg.go @@ -2,14 +2,17 @@ package analysisutil import ( "go/types" + "strconv" "strings" + + "golang.org/x/tools/go/analysis" ) -// RemoVendor removes vendoring infomation from import path. +// RemoVendor removes vendoring information from import path. func RemoveVendor(path string) string { - i := strings.Index(path, "vendor") + i := strings.Index(path, "vendor/") if i >= 0 { - return path[i+len("vendor")+1:] + return path[i+len("vendor/"):] } return path } @@ -24,3 +27,23 @@ func LookupFromImports(imports []*types.Package, path, name string) types.Object } return nil } + +// Imported returns true when the given pass imports the pkg. +func Imported(pkgPath string, pass *analysis.Pass) bool { + fs := pass.Files + if len(fs) == 0 { + return false + } + for _, f := range fs { + for _, i := range f.Imports { + path, err := strconv.Unquote(i.Path.Value) + if err != nil { + continue + } + if RemoveVendor(path) == pkgPath { + return true + } + } + } + return false +} -- cgit mrf-deployment