From 361bcb2be3eb3ebc2db2be295a33b4e3531f053d Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sat, 26 Mar 2016 06:16:12 +0100 Subject: [PATCH] all: address vet issues, fix print calls This fixes some print calls with wrong format directives. Additionally, struct initialisers were changed to use keyed fields, purely to reduce the amount of noise generated by go vet. Change-Id: Ib9f6fd8f2dff7ce84826478de0ba83dda9746270 Reviewed-on: https://go-review.googlesource.com/21180 Reviewed-by: Ian Lance Taylor --- cmd/bundle/main.go | 2 +- cmd/cover/cover.go | 2 +- cmd/guru/describe.go | 2 +- go/gcimporter15/bexport_test.go | 8 ++++---- go/loader/loader.go | 2 +- go/ssa/interp/interp_test.go | 2 +- godoc/analysis/typeinfo.go | 2 +- oracle/describe.go | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/bundle/main.go b/cmd/bundle/main.go index 5f38e354e0..962ccd01e3 100644 --- a/cmd/bundle/main.go +++ b/cmd/bundle/main.go @@ -151,7 +151,7 @@ func main() { wd, _ := os.Getwd() pkg, err := build.ImportDir(wd, 0) if err != nil { - log.Fatal("cannot find package in current directory: %v", err) + log.Fatalf("cannot find package in current directory: %v", err) } *dstPath = pkg.ImportPath if *pkgName == "" { diff --git a/cmd/cover/cover.go b/cmd/cover/cover.go index 31ec434546..e09336499b 100644 --- a/cmd/cover/cover.go +++ b/cmd/cover/cover.go @@ -374,7 +374,7 @@ func trimComments(file *ast.File, fset *token.FileSet) []*ast.CommentGroup { } } if list != nil { - comments = append(comments, &ast.CommentGroup{list}) + comments = append(comments, &ast.CommentGroup{List: list}) } } return comments diff --git a/cmd/guru/describe.go b/cmd/guru/describe.go index 2bec552fe0..b6ce6323f5 100644 --- a/cmd/guru/describe.go +++ b/cmd/guru/describe.go @@ -448,7 +448,7 @@ func describeType(qpos *queryPos, path []ast.Node) (*describeTypeResult, error) // Show sizes for structs and named types (it's fairly obvious for others). switch t.(type) { case *types.Named, *types.Struct: - szs := types.StdSizes{8, 8} // assume amd64 + szs := types.StdSizes{WordSize: 8, MaxAlign: 8} // assume amd64 description = fmt.Sprintf("%s (size %d, align %d)", description, szs.Sizeof(t), szs.Alignof(t)) } diff --git a/go/gcimporter15/bexport_test.go b/go/gcimporter15/bexport_test.go index 941f75156b..81a1154979 100644 --- a/go/gcimporter15/bexport_test.go +++ b/go/gcimporter15/bexport_test.go @@ -166,7 +166,7 @@ func equalType(x, y types.Type) error { xm := x.Method(i) ym := y.Method(i) if xm.Name() != ym.Name() { - return fmt.Errorf("mismatched %th method: %s vs %s", i, xm, ym) + return fmt.Errorf("mismatched %dth method: %s vs %s", i, xm, ym) } if err := equalType(xm.Type(), ym.Type()); err != nil { return fmt.Errorf("mismatched %s method: %s", xm.Name(), err) @@ -175,7 +175,7 @@ func equalType(x, y types.Type) error { case *types.Array: y := y.(*types.Array) if x.Len() != y.Len() { - return fmt.Errorf("unequal array lengths: %d vs %d", x, y) + return fmt.Errorf("unequal array lengths: %d vs %d", x.Len(), y.Len()) } if err := equalType(x.Elem(), y.Elem()); err != nil { return fmt.Errorf("array elements: %s", err) @@ -188,7 +188,7 @@ func equalType(x, y types.Type) error { case *types.Chan: y := y.(*types.Chan) if x.Dir() != y.Dir() { - return fmt.Errorf("unequal channel directions: %s vs %s", x.Dir(), y.Dir()) + return fmt.Errorf("unequal channel directions: %d vs %d", x.Dir(), y.Dir()) } if err := equalType(x.Elem(), y.Elem()); err != nil { return fmt.Errorf("channel elements: %s", err) @@ -263,7 +263,7 @@ func equalType(x, y types.Type) error { case *types.Tuple: y := y.(*types.Tuple) if x.Len() != y.Len() { - return fmt.Errorf("unequal tuple lengths: %d vs %d", x, y) + return fmt.Errorf("unequal tuple lengths: %d vs %d", x.Len(), y.Len()) } for i := 0; i < x.Len(); i++ { if err := equalType(x.At(i).Type(), y.At(i).Type()); err != nil { diff --git a/go/loader/loader.go b/go/loader/loader.go index 1ed0d3e237..f0171fc998 100644 --- a/go/loader/loader.go +++ b/go/loader/loader.go @@ -899,7 +899,7 @@ func (imp *importer) importAll(fromPath, fromDir string, imports map[string]bool // (Also it would complicate the // invariants of importPath completion.) if trace { - fmt.Fprintln(os.Stderr, "import cycle: %q", cycle) + fmt.Fprintf(os.Stderr, "import cycle: %q\n", cycle) } continue } diff --git a/go/ssa/interp/interp_test.go b/go/ssa/interp/interp_test.go index 5163816a2a..70c2f400d4 100644 --- a/go/ssa/interp/interp_test.go +++ b/go/ssa/interp/interp_test.go @@ -251,7 +251,7 @@ func run(t *testing.T, dir, input string, success successPredicate) bool { interp.CapturedOutput = &out hint = fmt.Sprintf("To trace execution, run:\n%% go build golang.org/x/tools/cmd/ssadump && ./ssadump -build=C -run --interp=T %s\n", input) - exitCode := interp.Interpret(mainPkg, 0, &types.StdSizes{8, 8}, inputs[0], []string{}) + exitCode := interp.Interpret(mainPkg, 0, &types.StdSizes{WordSize: 8, MaxAlign: 8}, inputs[0], []string{}) // The definition of success varies with each file. if err := success(exitCode, out.String()); err != nil { diff --git a/godoc/analysis/typeinfo.go b/godoc/analysis/typeinfo.go index 1ccff52ff5..5796a8526d 100644 --- a/godoc/analysis/typeinfo.go +++ b/godoc/analysis/typeinfo.go @@ -34,7 +34,7 @@ import ( // TODO(adonovan): audit to make sure it's safe on ill-typed packages. // TODO(adonovan): use same Sizes as loader.Config. -var sizes = types.StdSizes{8, 8} +var sizes = types.StdSizes{WordSize: 8, MaxAlign: 8} func (a *analysis) doTypeInfo(info *loader.PackageInfo, implements map[*types.Named]implementsFacts) { // We must not assume the corresponding SSA packages were diff --git a/oracle/describe.go b/oracle/describe.go index 70ddacfd7e..3be32df47e 100644 --- a/oracle/describe.go +++ b/oracle/describe.go @@ -442,7 +442,7 @@ func describeType(qpos *queryPos, path []ast.Node) (*describeTypeResult, error) // Show sizes for structs and named types (it's fairly obvious for others). switch t.(type) { case *types.Named, *types.Struct: - szs := types.StdSizes{8, 8} // assume amd64 + szs := types.StdSizes{WordSize: 8, MaxAlign: 8} // assume amd64 description = fmt.Sprintf("%s (size %d, align %d)", description, szs.Sizeof(t), szs.Alignof(t)) }