diff options
| author | Russ Cox <rsc@golang.org> | 2012-02-12 23:55:33 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-02-12 23:55:33 -0500 |
| commit | 878153682ecac3fb00bdad50ff8dcc296e30a701 (patch) | |
| tree | 3f3cc6945531bbc77811c2854ea251cd2eccb53e /src/cmd/fix | |
| parent | c58b6ad02203cc0f4ba3cd0a38ce222d177cc75e (diff) | |
| download | go-878153682ecac3fb00bdad50ff8dcc296e30a701.tar.xz | |
cmd/fix: warn about exp, old, deleted packages
Fixes #2776.
There was a previous attempt at CL 5592043 but that
seems to have stalled. This one is simpler, and more up to date
(correct handling of spdy, for example).
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5645091
Diffstat (limited to 'src/cmd/fix')
| -rw-r--r-- | src/cmd/fix/go1pkgrename.go | 25 | ||||
| -rw-r--r-- | src/cmd/fix/go1pkgrename_test.go | 10 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/cmd/fix/go1pkgrename.go b/src/cmd/fix/go1pkgrename.go index c1a11c83c8..f701f62f0a 100644 --- a/src/cmd/fix/go1pkgrename.go +++ b/src/cmd/fix/go1pkgrename.go @@ -6,6 +6,7 @@ package main import ( "go/ast" + "strings" ) func init() { @@ -76,10 +77,24 @@ var go1PackageRenames = []struct{ old, new string }{ {"net/dict", "code.google.com/p/go.net/dict"}, {"net/websocket", "code.google.com/p/go.net/websocket"}, {"exp/spdy", "code.google.com/p/go.net/spdy"}, + {"http/spdy", "code.google.com/p/go.net/spdy"}, // go.codereview sub-repository {"encoding/git85", "code.google.com/p/go.codereview/git85"}, {"patch", "code.google.com/p/go.codereview/patch"}, + + // exp + {"ebnf", "exp/ebnf"}, + {"go/types", "exp/types"}, + + // deleted + {"container/vector", ""}, + {"exp/datafmt", ""}, + {"go/typechecker", ""}, + {"old/netchan", ""}, + {"old/regexp", ""}, + {"old/template", ""}, + {"try", ""}, } var go1PackageNameRenames = []struct{ newPath, old, new string }{ @@ -92,12 +107,20 @@ func go1pkgrename(f *ast.File) bool { // First update the imports. for _, rename := range go1PackageRenames { - if !imports(f, rename.old) { + spec := importSpec(f, rename.old) + if spec == nil { + continue + } + if rename.new == "" { + warn(spec.Pos(), "package %q has been deleted in Go 1", rename.old) continue } if rewriteImport(f, rename.old, rename.new) { fixed = true } + if strings.HasPrefix(rename.new, "exp/") { + warn(spec.Pos(), "package %q is not part of Go 1", rename.new) + } } if !fixed { return false diff --git a/src/cmd/fix/go1pkgrename_test.go b/src/cmd/fix/go1pkgrename_test.go index 736e7ed7fc..22443f806b 100644 --- a/src/cmd/fix/go1pkgrename_test.go +++ b/src/cmd/fix/go1pkgrename_test.go @@ -87,6 +87,11 @@ import ( import "cmath" import poot "exp/template/html" +import ( + "ebnf" + "old/regexp" +) + var _ = cmath.Sin var _ = poot.Poot `, @@ -95,6 +100,11 @@ var _ = poot.Poot import "math/cmplx" import poot "html/template" +import ( + "exp/ebnf" + "old/regexp" +) + var _ = cmplx.Sin var _ = poot.Poot `, |
