Commit 71d83b72 authored by Rob Pike's avatar Rob Pike

cmd/go: add go tools to rearrangement

fix, vet
yacc is also fixed (it was wrong before)
All that's left is the commands used during compilation
This looks like a huge CL, but it's almost all file renames.
The action is in cmd/go/pkg.go, the Makefiles, and .../doc.go.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5595044
parent 108961b2
......@@ -38,10 +38,11 @@ CLEANDIRS=\
8l\
cgo\
godoc\
gofix\
fix\
gofmt\
goinstall\
gotest\
vet\
yacc\
install: $(patsubst %,%.install,$(DIRS))
......
......@@ -44,7 +44,7 @@ GOFILES=\
url.go\
xmlapi.go\
include ../../Make.cmd
include ../../Make.tool
test:
gotest
......
......@@ -3,34 +3,34 @@
// license that can be found in the LICENSE file.
/*
Gofix finds Go programs that use old APIs and rewrites them to use
newer ones. After you update to a new Go release, gofix helps make
Fix finds Go programs that use old APIs and rewrites them to use
newer ones. After you update to a new Go release, fix helps make
the necessary changes to your programs.
Usage:
gofix [-r name,...] [path ...]
go tool fix [-r name,...] [path ...]
Without an explicit path, gofix reads standard input and writes the
Without an explicit path, fix reads standard input and writes the
result to standard output.
If the named path is a file, gofix rewrites the named files in place.
If the named path is a directory, gofix rewrites all .go files in that
directory tree. When gofix rewrites a file, it prints a line to standard
If the named path is a file, fix rewrites the named files in place.
If the named path is a directory, fix rewrites all .go files in that
directory tree. When fix rewrites a file, it prints a line to standard
error giving the name of the file and the rewrite applied.
If the -diff flag is set, no files are rewritten. Instead gofix prints
If the -diff flag is set, no files are rewritten. Instead fix prints
the differences a rewrite would introduce.
The -r flag restricts the set of rewrites considered to those in the
named list. By default gofix considers all known rewrites. Gofix's
rewrites are idempotent, so that it is safe to apply gofix to updated
named list. By default fix considers all known rewrites. Fix's
rewrites are idempotent, so that it is safe to apply fix to updated
or partially updated code even without using the -r flag.
Gofix prints the full list of fixes it can apply in its help output;
to see them, run gofix -?.
Fix prints the full list of fixes it can apply in its help output;
to see them, run go tool fix -?.
Gofix does not make backup copies of the files that it edits.
Fix does not make backup copies of the files that it edits.
Instead, use a version control system's ``diff'' functionality to inspect
the changes that gofix makes before committing them.
the changes that fix makes before committing them.
*/
package documentation
......@@ -36,11 +36,11 @@ var allowed, force map[string]bool
var doDiff = flag.Bool("diff", false, "display diffs instead of rewriting files")
// enable for debugging gofix failures
// enable for debugging fix failures
const debug = false // display incorrectly reformatted source and exit
func usage() {
fmt.Fprintf(os.Stderr, "usage: gofix [-diff] [-r fixname,...] [-force fixname,...] [path ...]\n")
fmt.Fprintf(os.Stderr, "usage: go tool fix [-diff] [-r fixname,...] [-force fixname,...] [path ...]\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nAvailable rewrites are:\n")
sort.Sort(byName(fixes))
......@@ -244,14 +244,14 @@ func isGoFile(f os.FileInfo) bool {
}
func diff(b1, b2 []byte) (data []byte, err error) {
f1, err := ioutil.TempFile("", "gofix")
f1, err := ioutil.TempFile("", "go-fix")
if err != nil {
return nil, err
}
defer os.Remove(f1.Name())
defer f1.Close()
f2, err := ioutil.TempFile("", "gofix")
f2, err := ioutil.TempFile("", "go-fix")
if err != nil {
return nil, err
}
......
......@@ -87,8 +87,8 @@ http://codereview.appspot.com/4433066
// x.(*reflect.MapValue).Elem(v) becomes x.MapIndex(v).
// In general, reflectFn needs to know the type of the receiver expression.
// In most cases (and in all the cases in the Go source tree), the toy
// type checker in typecheck.go provides enough information for gofix
// to make the rewrite. If gofix misses a rewrite, the code that is left over
// type checker in typecheck.go provides enough information for fix
// to make the rewrite. If fix misses a rewrite, the code that is left over
// will not compile, so it will be noticed immediately.
func reflectFn(f *ast.File) bool {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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