diff options
author | Alan Donovan <adonovan@google.com> | 2015-03-02 14:23:59 -0500 |
---|---|---|
committer | Alan Donovan <adonovan@google.com> | 2015-03-02 19:38:58 +0000 |
commit | 4744be3abc70249546ce31c32fa9b5a5e96b5ad1 (patch) | |
tree | f81c0a5ad3408cabefad7c9120cc5b238dddbca0 | |
parent | 133ecf9210d4e3560916c6e5ece2b91a97399a9d (diff) | |
download | tools-4744be3abc70249546ce31c32fa9b5a5e96b5ad1.tar.gz |
refactor/eg: use format.Node not printer.Fprint for canonical output
Fixes golang/go#10038
Change-Id: If3243f0c68fc0442dcc1e2dd71cbdc629beff70c
Reviewed-on: https://go-review.googlesource.com/6481
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
-rw-r--r-- | refactor/eg/eg.go | 3 | ||||
-rw-r--r-- | refactor/eg/testdata/A1.golden | 2 | ||||
-rw-r--r-- | refactor/eg/testdata/A2.golden | 2 | ||||
-rw-r--r-- | refactor/eg/testdata/D1.golden | 8 | ||||
-rw-r--r-- | refactor/eg/testdata/E1.golden | 4 |
5 files changed, 10 insertions, 9 deletions
diff --git a/refactor/eg/eg.go b/refactor/eg/eg.go index a107204..7d37ec6 100644 --- a/refactor/eg/eg.go +++ b/refactor/eg/eg.go @@ -6,6 +6,7 @@ import ( "bytes" "fmt" "go/ast" + "go/format" "go/printer" "go/token" "os" @@ -288,7 +289,7 @@ func WriteAST(fset *token.FileSet, filename string, f *ast.File) (err error) { err = err2 // prefer earlier error } }() - return printer.Fprint(fh, fset, f) + return format.Node(fh, fset, f) } // -- utilities -------------------------------------------------------- diff --git a/refactor/eg/testdata/A1.golden b/refactor/eg/testdata/A1.golden index 4f7ba82..7eb2934 100644 --- a/refactor/eg/testdata/A1.golden +++ b/refactor/eg/testdata/A1.golden @@ -3,8 +3,8 @@ package A1 import ( - . "fmt" "errors" + . "fmt" myfmt "fmt" "os" "strings" diff --git a/refactor/eg/testdata/A2.golden b/refactor/eg/testdata/A2.golden index 5c2384b..b6e3a6d 100644 --- a/refactor/eg/testdata/A2.golden +++ b/refactor/eg/testdata/A2.golden @@ -6,8 +6,8 @@ package A2 // TODO(adonovan): fix: it should also remove "fmt". import ( - myfmt "fmt" "errors" + myfmt "fmt" ) func example(n int) { diff --git a/refactor/eg/testdata/D1.golden b/refactor/eg/testdata/D1.golden index 3f2dc59..2932652 100644 --- a/refactor/eg/testdata/D1.golden +++ b/refactor/eg/testdata/D1.golden @@ -5,8 +5,8 @@ package D1 import "fmt" func example() { - fmt.Println(456, "!") // match - fmt.Println(456, "!") // match - fmt.Println(456, "!") // match - fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals + fmt.Println(456, "!") // match + fmt.Println(456, "!") // match + fmt.Println(456, "!") // match + fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals } diff --git a/refactor/eg/testdata/E1.golden b/refactor/eg/testdata/E1.golden index a0adfc8..796364f 100644 --- a/refactor/eg/testdata/E1.golden +++ b/refactor/eg/testdata/E1.golden @@ -3,11 +3,11 @@ package E1 import ( + "fmt" "log" "os" - "fmt" ) func example() { - fmt.Fprintf(os.Stderr, "warning: %v", "oops") // match + fmt.Fprintf(os.Stderr, "warning: %v", "oops") // match } |