From c7d7f10bdff703e4a3c0414e8a33d4e45c91eb35 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 4 Jul 2020 11:12:55 +0200 Subject: go.mod: vendor golangci-lint --- .../gostaticanalysis/analysisutil/pkg.go | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 vendor/github.com/gostaticanalysis/analysisutil/pkg.go (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 new file mode 100644 index 000000000..c98710d18 --- /dev/null +++ b/vendor/github.com/gostaticanalysis/analysisutil/pkg.go @@ -0,0 +1,26 @@ +package analysisutil + +import ( + "go/types" + "strings" +) + +// RemoVendor removes vendoring infomation from import path. +func RemoveVendor(path string) string { + i := strings.Index(path, "vendor") + if i >= 0 { + return path[i+len("vendor")+1:] + } + return path +} + +// LookupFromImports finds an object from import paths. +func LookupFromImports(imports []*types.Package, path, name string) types.Object { + path = RemoveVendor(path) + for i := range imports { + if path == RemoveVendor(imports[i].Path()) { + return imports[i].Scope().Lookup(name) + } + } + return nil +} -- cgit mrf-deployment