1
0
mirror of https://github.com/golang/go synced 2024-11-18 12:54:44 -07:00

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 <iant@golang.org>
This commit is contained in:
Dominik Honnef 2016-03-26 06:16:12 +01:00 committed by Ian Lance Taylor
parent 3b9441cce4
commit 361bcb2be3
8 changed files with 11 additions and 11 deletions

View File

@ -151,7 +151,7 @@ func main() {
wd, _ := os.Getwd() wd, _ := os.Getwd()
pkg, err := build.ImportDir(wd, 0) pkg, err := build.ImportDir(wd, 0)
if err != nil { 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 *dstPath = pkg.ImportPath
if *pkgName == "" { if *pkgName == "" {

View File

@ -374,7 +374,7 @@ func trimComments(file *ast.File, fset *token.FileSet) []*ast.CommentGroup {
} }
} }
if list != nil { if list != nil {
comments = append(comments, &ast.CommentGroup{list}) comments = append(comments, &ast.CommentGroup{List: list})
} }
} }
return comments return comments

View File

@ -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). // Show sizes for structs and named types (it's fairly obvious for others).
switch t.(type) { switch t.(type) {
case *types.Named, *types.Struct: 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, description = fmt.Sprintf("%s (size %d, align %d)", description,
szs.Sizeof(t), szs.Alignof(t)) szs.Sizeof(t), szs.Alignof(t))
} }

View File

@ -166,7 +166,7 @@ func equalType(x, y types.Type) error {
xm := x.Method(i) xm := x.Method(i)
ym := y.Method(i) ym := y.Method(i)
if xm.Name() != ym.Name() { 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 { if err := equalType(xm.Type(), ym.Type()); err != nil {
return fmt.Errorf("mismatched %s method: %s", xm.Name(), err) return fmt.Errorf("mismatched %s method: %s", xm.Name(), err)
@ -175,7 +175,7 @@ func equalType(x, y types.Type) error {
case *types.Array: case *types.Array:
y := y.(*types.Array) y := y.(*types.Array)
if x.Len() != y.Len() { 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 { if err := equalType(x.Elem(), y.Elem()); err != nil {
return fmt.Errorf("array elements: %s", err) return fmt.Errorf("array elements: %s", err)
@ -188,7 +188,7 @@ func equalType(x, y types.Type) error {
case *types.Chan: case *types.Chan:
y := y.(*types.Chan) y := y.(*types.Chan)
if x.Dir() != y.Dir() { 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 { if err := equalType(x.Elem(), y.Elem()); err != nil {
return fmt.Errorf("channel elements: %s", err) return fmt.Errorf("channel elements: %s", err)
@ -263,7 +263,7 @@ func equalType(x, y types.Type) error {
case *types.Tuple: case *types.Tuple:
y := y.(*types.Tuple) y := y.(*types.Tuple)
if x.Len() != y.Len() { 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++ { for i := 0; i < x.Len(); i++ {
if err := equalType(x.At(i).Type(), y.At(i).Type()); err != nil { if err := equalType(x.At(i).Type(), y.At(i).Type()); err != nil {

View File

@ -899,7 +899,7 @@ func (imp *importer) importAll(fromPath, fromDir string, imports map[string]bool
// (Also it would complicate the // (Also it would complicate the
// invariants of importPath completion.) // invariants of importPath completion.)
if trace { if trace {
fmt.Fprintln(os.Stderr, "import cycle: %q", cycle) fmt.Fprintf(os.Stderr, "import cycle: %q\n", cycle)
} }
continue continue
} }

View File

@ -251,7 +251,7 @@ func run(t *testing.T, dir, input string, success successPredicate) bool {
interp.CapturedOutput = &out 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) 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. // The definition of success varies with each file.
if err := success(exitCode, out.String()); err != nil { if err := success(exitCode, out.String()); err != nil {

View File

@ -34,7 +34,7 @@ import (
// TODO(adonovan): audit to make sure it's safe on ill-typed packages. // TODO(adonovan): audit to make sure it's safe on ill-typed packages.
// TODO(adonovan): use same Sizes as loader.Config. // 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) { func (a *analysis) doTypeInfo(info *loader.PackageInfo, implements map[*types.Named]implementsFacts) {
// We must not assume the corresponding SSA packages were // We must not assume the corresponding SSA packages were

View File

@ -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). // Show sizes for structs and named types (it's fairly obvious for others).
switch t.(type) { switch t.(type) {
case *types.Named, *types.Struct: 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, description = fmt.Sprintf("%s (size %d, align %d)", description,
szs.Sizeof(t), szs.Alignof(t)) szs.Sizeof(t), szs.Alignof(t))
} }