go.tools: fix various minor issues found by go vet

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/96360048
This commit is contained in:
Rob Pike 2014-05-19 08:47:28 -07:00
parent 31d5e8dca1
commit 6f17d00f0d
7 changed files with 20 additions and 22 deletions

View File

@ -182,7 +182,7 @@ func TestTypeAnalysis(t *testing.T) {
// Write a fake GOROOT/GOPATH.
tmpdir, err := ioutil.TempDir("", "godoc-analysis")
if err != nil {
t.Fatal("ioutil.TempDir failed: %s", err)
t.Fatalf("ioutil.TempDir failed: %s", err)
}
defer os.RemoveAll(tmpdir)
for _, f := range []struct{ file, content string }{

View File

@ -71,17 +71,17 @@ func TestMoreBasics(t *testing.T) {
t.Errorf("%s.Len: got %d, want 3", set, set.Len())
}
if set.IsEmpty() {
t.Error("%s.IsEmpty: got true", set)
t.Errorf("%s.IsEmpty: got true", set)
}
if !set.Has(123) {
t.Error("%s.Has(123): got false", set)
t.Errorf("%s.Has(123): got false", set)
}
if set.Has(1234) {
t.Error("%s.Has(1234): got true", set)
t.Errorf("%s.Has(1234): got true", set)
}
got := set.AppendTo([]int{-1})
if want := []int{-1, 123, 456, 789}; fmt.Sprint(got) != fmt.Sprint(want) {
t.Error("%s.AppendTo: got %v, want %v", got, want)
t.Errorf("%s.AppendTo: got %v, want %v", got, want)
}
set.Clear()
@ -90,10 +90,10 @@ func TestMoreBasics(t *testing.T) {
t.Errorf("Clear: got %d, want 0", set.Len())
}
if !set.IsEmpty() {
t.Error("IsEmpty: got false")
t.Errorf("IsEmpty: got false")
}
if set.Has(123) {
t.Error("%s.Has: got false", set)
t.Errorf("%s.Has: got false", set)
}
}
@ -440,7 +440,7 @@ func TestFailFastOnShallowCopy(t *testing.T) {
got := fmt.Sprint(recover())
want := "A Sparse has been copied without (*Sparse).Copy()"
if got != want {
t.Error("shallow copy: recover() = %q, want %q", got, want)
t.Errorf("shallow copy: recover() = %q, want %q", got, want)
}
}()
y.String() // panics

View File

@ -101,11 +101,16 @@ func TestLoadFromArgsSource(t *testing.T) {
args = []string{"testdata/a.go", "testdata/b.go"}
prog, _, err = loadFromArgs(args)
if err != nil {
t.Errorf("loadFromArgs(%q) failed: %s", args, err)
return
t.Fatalf("loadFromArgs(%q) failed: %s", args, err)
}
if len(prog.Created) != 1 || prog.Created[0].Pkg.Path() != "P" {
t.Errorf("loadFromArgs(%q): got %v, want [P]", prog.Created)
if len(prog.Created) != 1 {
t.Errorf("loadFromArgs(%q): got %d items, want 1", len(prog.Created))
}
if len(prog.Created) > 0 {
path := prog.Created[0].Pkg.Path()
if path != "P" {
t.Errorf("loadFromArgs(%q): got %v, want [P]", prog.Created, path)
}
}
}
@ -190,7 +195,7 @@ func TestTransitivelyErrorFreeFlag(t *testing.T) {
if info.TransitivelyErrorFree != wantTEF {
t.Errorf("Package %q.TransitivelyErrorFree=%t, want %t",
info.TransitivelyErrorFree, wantTEF)
pkg.Path(), info.TransitivelyErrorFree, wantTEF)
}
}
}

View File

@ -276,7 +276,6 @@ func ext۰reflect۰Value۰Len(fr *frame, args []value) value {
default:
panic(fmt.Sprintf("reflect.(Value).Len(%v)", v))
}
return nil // unreachable
}
func ext۰reflect۰Value۰MapIndex(fr *frame, args []value) value {
@ -353,7 +352,6 @@ func ext۰reflect۰Value۰Pointer(fr *frame, args []value) value {
default:
panic(fmt.Sprintf("reflect.(Value).Pointer(%T)", v))
}
return nil // unreachable
}
func ext۰reflect۰Value۰Index(fr *frame, args []value) value {
@ -368,7 +366,6 @@ func ext۰reflect۰Value۰Index(fr *frame, args []value) value {
default:
panic(fmt.Sprintf("reflect.(Value).Index(%T)", v))
}
return nil // unreachable
}
func ext۰reflect۰Value۰Bool(fr *frame, args []value) value {
@ -398,7 +395,6 @@ func ext۰reflect۰Value۰Elem(fr *frame, args []value) value {
default:
panic(fmt.Sprintf("reflect.(Value).Elem(%T)", x))
}
return nil // unreachable
}
func ext۰reflect۰Value۰Field(fr *frame, args []value) value {
@ -440,7 +436,6 @@ func ext۰reflect۰Value۰Int(fr *frame, args []value) value {
default:
panic(fmt.Sprintf("reflect.(Value).Int(%T)", x))
}
return nil // unreachable
}
func ext۰reflect۰Value۰IsNil(fr *frame, args []value) value {
@ -467,7 +462,6 @@ func ext۰reflect۰Value۰IsNil(fr *frame, args []value) value {
default:
panic(fmt.Sprintf("reflect.(Value).IsNil(%T)", x))
}
return nil // unreachable
}
func ext۰reflect۰Value۰IsValid(fr *frame, args []value) value {

View File

@ -59,7 +59,6 @@ func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) {
})
}
}
return
}
// attrValue returns the attribute value for the case-insensitive key

View File

@ -500,7 +500,7 @@ func (a *analysis) pointer(mainPkgs []*ssa.Package) {
ptares, err := pointer.Analyze(&a.ptaConfig)
if err != nil {
// If this happens, it indicates a bug.
log.Print("Pointer analysis failed: %s", err)
log.Printf("Pointer analysis failed: %s", err)
return
}
log.Print("Pointer analysis complete.")

View File

@ -98,7 +98,7 @@ func (a *analysis) doCallgraph(cg *callgraph.Graph) {
for callee, sites := range callingSites {
pos := funcToken(callee)
if pos == token.NoPos {
log.Print("CALLERS: skipping %s: no pos", callee)
log.Printf("CALLERS: skipping %s: no pos", callee)
continue
}