diff --git a/cmd/godoc/godoc_test.go b/cmd/godoc/godoc_test.go index dd0ded42..b0a4ef0b 100644 --- a/cmd/godoc/godoc_test.go +++ b/cmd/godoc/godoc_test.go @@ -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 }{ diff --git a/container/intsets/sparse_test.go b/container/intsets/sparse_test.go index cd814c7a..258291af 100644 --- a/container/intsets/sparse_test.go +++ b/container/intsets/sparse_test.go @@ -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 diff --git a/go/loader/importer_test.go b/go/loader/importer_test.go index f984f93b..c6f04450 100644 --- a/go/loader/importer_test.go +++ b/go/loader/importer_test.go @@ -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) } } } diff --git a/go/ssa/interp/reflect.go b/go/ssa/interp/reflect.go index 76926578..53bc614a 100644 --- a/go/ssa/interp/reflect.go +++ b/go/ssa/interp/reflect.go @@ -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 { diff --git a/go/vcs/discovery.go b/go/vcs/discovery.go index c9b3caf9..d5c3fc6b 100644 --- a/go/vcs/discovery.go +++ b/go/vcs/discovery.go @@ -59,7 +59,6 @@ func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) { }) } } - return } // attrValue returns the attribute value for the case-insensitive key diff --git a/godoc/analysis/analysis.go b/godoc/analysis/analysis.go index 1e2b79a8..ddf4dcd1 100644 --- a/godoc/analysis/analysis.go +++ b/godoc/analysis/analysis.go @@ -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.") diff --git a/godoc/analysis/callgraph.go b/godoc/analysis/callgraph.go index ad893922..4db50c7b 100644 --- a/godoc/analysis/callgraph.go +++ b/godoc/analysis/callgraph.go @@ -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 }