1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:04:49 -07:00

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>
This commit is contained in:
Alan Donovan 2015-03-02 14:23:59 -05:00
parent 133ecf9210
commit 4744be3abc
5 changed files with 10 additions and 9 deletions

View File

@ -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 --------------------------------------------------------

View File

@ -3,8 +3,8 @@
package A1
import (
. "fmt"
"errors"
. "fmt"
myfmt "fmt"
"os"
"strings"

View File

@ -6,8 +6,8 @@ package A2
// TODO(adonovan): fix: it should also remove "fmt".
import (
myfmt "fmt"
"errors"
myfmt "fmt"
)
func example(n int) {

View File

@ -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
}

View File

@ -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
}