Commit 844889df authored by Andrew Gerrand's avatar Andrew Gerrand

cmd/go: use golang.org/x/... import paths

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168170043
parent 7f0be1f7
...@@ -590,7 +590,7 @@ Usage: ...@@ -590,7 +590,7 @@ Usage:
Vet runs the Go vet command on the packages named by the import paths. Vet runs the Go vet command on the packages named by the import paths.
For more about vet, see 'godoc code.google.com/p/go.tools/cmd/vet'. For more about vet, see 'godoc golang.org/x/tools/cmd/vet'.
For more about specifying packages, see 'go help packages'. For more about specifying packages, see 'go help packages'.
To run the vet tool with specific options, run 'go tool vet'. To run the vet tool with specific options, run 'go tool vet'.
......
...@@ -383,9 +383,10 @@ func findInternal(path string) (index int, ok bool) { ...@@ -383,9 +383,10 @@ func findInternal(path string) (index int, ok bool) {
type targetDir int type targetDir int
const ( const (
toRoot targetDir = iota // to bin dir inside package root (default) toRoot targetDir = iota // to bin dir inside package root (default)
toTool // GOROOT/pkg/tool toTool // GOROOT/pkg/tool
toBin // GOROOT/bin toBin // GOROOT/bin
stalePath // the old import path; fail to build
) )
// goTools is a map of Go program import path to install target directory. // goTools is a map of Go program import path to install target directory.
...@@ -399,9 +400,12 @@ var goTools = map[string]targetDir{ ...@@ -399,9 +400,12 @@ var goTools = map[string]targetDir{
"cmd/objdump": toTool, "cmd/objdump": toTool,
"cmd/pack": toTool, "cmd/pack": toTool,
"cmd/yacc": toTool, "cmd/yacc": toTool,
"code.google.com/p/go.tools/cmd/cover": toTool, "golang.org/x/tools/cmd/cover": toTool,
"code.google.com/p/go.tools/cmd/godoc": toBin, "golang.org/x/tools/cmd/godoc": toBin,
"code.google.com/p/go.tools/cmd/vet": toTool, "golang.org/x/tools/cmd/vet": toTool,
"code.google.com/p/go.tools/cmd/cover": stalePath,
"code.google.com/p/go.tools/cmd/godoc": stalePath,
"code.google.com/p/go.tools/cmd/vet": stalePath,
} }
// expandScanner expands a scanner.List error into all the errors in the list. // expandScanner expands a scanner.List error into all the errors in the list.
...@@ -462,6 +466,13 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package ...@@ -462,6 +466,13 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
} }
if p.Name == "main" { if p.Name == "main" {
// Report an error when the old code.google.com/p/go.tools paths are used.
if goTools[p.ImportPath] == stalePath {
newPath := strings.Replace(p.ImportPath, "code.google.com/p/go.", "golang.org/x/", 1)
e := fmt.Sprintf("the %v command has moved; use %v instead.", p.ImportPath, newPath)
p.Error = &PackageError{Err: e}
return p
}
_, elem := filepath.Split(p.Dir) _, elem := filepath.Split(p.Dir)
full := buildContext.GOOS + "_" + buildContext.GOARCH + "/" + elem full := buildContext.GOOS + "_" + buildContext.GOARCH + "/" + elem
if buildContext.GOOS != toolGOOS || buildContext.GOARCH != toolGOARCH { if buildContext.GOOS != toolGOOS || buildContext.GOARCH != toolGOARCH {
......
...@@ -433,20 +433,20 @@ TEST godoc installs into GOBIN ...@@ -433,20 +433,20 @@ TEST godoc installs into GOBIN
d=$(mktemp -d -t testgoXXX) d=$(mktemp -d -t testgoXXX)
export GOPATH=$d export GOPATH=$d
mkdir $d/gobin mkdir $d/gobin
GOBIN=$d/gobin ./testgo get code.google.com/p/go.tools/cmd/godoc || ok=false GOBIN=$d/gobin ./testgo get golang.org/x/tools/cmd/godoc || ok=false
if [ ! -x $d/gobin/godoc ]; then if [ ! -x $d/gobin/godoc ]; then
echo did not install godoc to '$GOBIN' echo did not install godoc to '$GOBIN'
GOBIN=$d/gobin ./testgo list -f 'Target: {{.Target}}' code.google.com/p/go.tools/cmd/godoc || true GOBIN=$d/gobin ./testgo list -f 'Target: {{.Target}}' golang.org/x/tools/cmd/godoc || true
ok=false ok=false
fi fi
TEST godoc installs into GOROOT TEST godoc installs into GOROOT
GOROOT=$(./testgo env GOROOT) GOROOT=$(./testgo env GOROOT)
rm -f $GOROOT/bin/godoc rm -f $GOROOT/bin/godoc
./testgo install code.google.com/p/go.tools/cmd/godoc || ok=false ./testgo install golang.org/x/tools/cmd/godoc || ok=false
if [ ! -x $GOROOT/bin/godoc ]; then if [ ! -x $GOROOT/bin/godoc ]; then
echo did not install godoc to '$GOROOT/bin' echo did not install godoc to '$GOROOT/bin'
./testgo list -f 'Target: {{.Target}}' code.google.com/p/go.tools/cmd/godoc || true ./testgo list -f 'Target: {{.Target}}' golang.org/x/tools/cmd/godoc || true
ok=false ok=false
fi fi
...@@ -561,8 +561,8 @@ fi ...@@ -561,8 +561,8 @@ fi
TEST without GOPATH, go get fails TEST without GOPATH, go get fails
d=$(mktemp -d -t testgoXXX) d=$(mktemp -d -t testgoXXX)
mkdir -p $d/src mkdir -p $d/src
if GOPATH= GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch ; then if GOPATH= GOROOT=$d ./testgo get -d golang.org/x/codereview/cmd/hgpatch ; then
echo 'go get code.google.com/p/go.codereview/cmd/hgpatch should not succeed with $GOPATH unset' echo 'go get golang.org/x/codereview/cmd/hgpatch should not succeed with $GOPATH unset'
ok=false ok=false
fi fi
rm -rf $d rm -rf $d
...@@ -571,8 +571,8 @@ rm -rf $d ...@@ -571,8 +571,8 @@ rm -rf $d
TEST with GOPATH=GOROOT, go get fails TEST with GOPATH=GOROOT, go get fails
d=$(mktemp -d -t testgoXXX) d=$(mktemp -d -t testgoXXX)
mkdir -p $d/src mkdir -p $d/src
if GOPATH=$d GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch ; then if GOPATH=$d GOROOT=$d ./testgo get -d golang.org/x/codereview/cmd/hgpatch ; then
echo 'go get code.google.com/p/go.codereview/cmd/hgpatch should not succeed with GOPATH=$GOROOT' echo 'go get golang.org/x/codereview/cmd/hgpatch should not succeed with GOPATH=$GOROOT'
ok=false ok=false
fi fi
rm -rf $d rm -rf $d
...@@ -728,7 +728,7 @@ elif ! grep "case-insensitive file name collision" $d/out >/dev/null; then ...@@ -728,7 +728,7 @@ elif ! grep "case-insensitive file name collision" $d/out >/dev/null; then
fi fi
TEST go get cover TEST go get cover
./testgo get code.google.com/p/go.tools/cmd/cover || ok=false ./testgo get golang.org/x/tools/cmd/cover || ok=false
unset GOPATH unset GOPATH
rm -rf $d rm -rf $d
......
...@@ -53,7 +53,7 @@ func tool(toolName string) string { ...@@ -53,7 +53,7 @@ func tool(toolName string) string {
// Give a nice message if there is no tool with that name. // Give a nice message if there is no tool with that name.
if _, err := os.Stat(toolPath); err != nil { if _, err := os.Stat(toolPath); err != nil {
if isInGoToolsRepo(toolName) { if isInGoToolsRepo(toolName) {
fmt.Fprintf(os.Stderr, "go tool: no such tool %q; to install:\n\tgo get code.google.com/p/go.tools/cmd/%s\n", toolName, toolName) fmt.Fprintf(os.Stderr, "go tool: no such tool %q; to install:\n\tgo get golang.org/x/tools/cmd/%s\n", toolName, toolName)
} else { } else {
fmt.Fprintf(os.Stderr, "go tool: no such tool %q\n", toolName) fmt.Fprintf(os.Stderr, "go tool: no such tool %q\n", toolName)
} }
......
...@@ -17,7 +17,7 @@ var cmdVet = &Command{ ...@@ -17,7 +17,7 @@ var cmdVet = &Command{
Long: ` Long: `
Vet runs the Go vet command on the packages named by the import paths. Vet runs the Go vet command on the packages named by the import paths.
For more about vet, see 'godoc code.google.com/p/go.tools/cmd/vet'. For more about vet, see 'godoc golang.org/x/tools/cmd/vet'.
For more about specifying packages, see 'go help packages'. For more about specifying packages, see 'go help packages'.
To run the vet tool with specific options, run 'go tool vet'. To run the vet tool with specific options, run 'go tool vet'.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment