diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-30 00:12:53 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-30 00:13:03 +0000 |
commit | b66e054640c8249b6bc92cebffaec2bcf8b5efd0 (patch) | |
tree | 548140b1c771403af3133d02586a14cfb358635a /refactor | |
parent | cbfb669053f449915d8520a0e5c87240ec4d3e13 (diff) | |
download | golang-x-tools-b66e054640c8249b6bc92cebffaec2bcf8b5efd0.tar.gz |
Revert "refactor/eg: remove vendor prefix from imported packages"
This reverts commit c060f04f93f57c44284360be78bb323077183645.
Reason for revert: breaks the build. Nobody ran tests.
Change-Id: I981101eb503e8cebd6f7b5640299d106ca733b33
Reviewed-on: https://go-review.googlesource.com/33674
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'refactor')
-rw-r--r-- | refactor/eg/rewrite.go | 18 | ||||
-rw-r--r-- | refactor/eg/rewrite_test.go | 36 |
2 files changed, 1 insertions, 53 deletions
diff --git a/refactor/eg/rewrite.go b/refactor/eg/rewrite.go index 49710e17e..d91a99ccc 100644 --- a/refactor/eg/rewrite.go +++ b/refactor/eg/rewrite.go @@ -98,7 +98,7 @@ func (tr *Transformer) Transform(info *types.Info, pkg *types.Package, file *ast if tr.nsubsts > 0 { pkgs := make(map[string]*types.Package) for obj := range tr.importedObjs { - pkgs[vendorlessImportPath(obj.Pkg().Path())] = obj.Pkg() + pkgs[obj.Pkg().Path()] = obj.Pkg() } for _, imp := range file.Imports { @@ -344,19 +344,3 @@ func updateTypeInfo(info *types.Info, new, old ast.Expr) { info.Types[new] = tv } } - -// vendorlessImportPath returns the devendorized version of the provided import path. -// e.g. "foo/bar/vendor/a/b" => "a/b" -// -// This function is taken from fix.go in the golang.org/x/tools/imports -// package. -func vendorlessImportPath(ipath string) string { - // Devendorize for use in import statement. - if i := strings.LastIndex(ipath, "/vendor/"); i >= 0 { - return ipath[i+len("/vendor/"):] - } - if strings.HasPrefix(ipath, "vendor/") { - return ipath[len("vendor/"):] - } - return ipath -} diff --git a/refactor/eg/rewrite_test.go b/refactor/eg/rewrite_test.go deleted file mode 100644 index 382aab7c9..000000000 --- a/refactor/eg/rewrite_test.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package eg - -import "testing" - -func TestVendorlessImportPath(t *testing.T) { - tests := []struct { - path string - ipath string - }{ - {"a/b/c", "a/b/c"}, - {"a/b/vendor/c", "c"}, - {"a/vendor/b/c", "b/c"}, - {"vendor/a/b/c", "a/b/c"}, - {"a/b/vendor/vendor/c", "c"}, - {"a/vendor/b/vendor/c", "c"}, - {"vendor/a/b/vendor/c", "c"}, - {"vendor/a/vendor/b/c", "b/c"}, - {"a/vendor/vendor/b/c", "b/c"}, - {"vendor/vendor/a/b/c", "a/b/c"}, - - {"a/b/notvendor/c", "a/b/notvendor/c"}, - {"a/b/vendors/c", "a/b/vendors/c"}, - {"a/b/notvendors/c", "a/b/notvendors/c"}, - {"notvendor/a/b/c", "notvendor/a/b/c"}, - } - - for _, tt := range tests { - if have, want := vendorlessImportPath(tt.path), tt.ipath; have != want { - t.Errorf("vendorlessImportPath(%q); %q != %q", tt.path, have, want) - } - } -} |