1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:24:41 -07:00

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
This commit is contained in:
Rob Pike 2012-01-29 11:07:25 -08:00
parent 108961b216
commit 71d83b72ef
117 changed files with 77 additions and 64 deletions

View File

@ -38,10 +38,11 @@ CLEANDIRS=\
8l\
cgo\
godoc\
gofix\
fix\
gofmt\
goinstall\
gotest\
vet\
yacc\
install: $(patsubst %,%.install,$(DIRS))

View File

@ -44,7 +44,7 @@ GOFILES=\
url.go\
xmlapi.go\
include ../../Make.cmd
include ../../Make.tool
test:
gotest

36
src/cmd/fix/doc.go Normal file
View File

@ -0,0 +1,36 @@
// Copyright 2011 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.
/*
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:
go tool fix [-r name,...] [path ...]
Without an explicit path, fix reads standard input and writes the
result to standard output.
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 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 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.
Fix prints the full list of fixes it can apply in its help output;
to see them, run go tool fix -?.
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 fix makes before committing them.
*/
package documentation

View File

@ -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
}

View File

@ -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 {

Some files were not shown because too many files have changed in this diff Show More