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:
parent
133ecf9210
commit
4744be3abc
@ -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 --------------------------------------------------------
|
||||
|
2
refactor/eg/testdata/A1.golden
vendored
2
refactor/eg/testdata/A1.golden
vendored
@ -3,8 +3,8 @@
|
||||
package A1
|
||||
|
||||
import (
|
||||
. "fmt"
|
||||
"errors"
|
||||
. "fmt"
|
||||
myfmt "fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
2
refactor/eg/testdata/A2.golden
vendored
2
refactor/eg/testdata/A2.golden
vendored
@ -6,8 +6,8 @@ package A2
|
||||
// TODO(adonovan): fix: it should also remove "fmt".
|
||||
|
||||
import (
|
||||
myfmt "fmt"
|
||||
"errors"
|
||||
myfmt "fmt"
|
||||
)
|
||||
|
||||
func example(n int) {
|
||||
|
8
refactor/eg/testdata/D1.golden
vendored
8
refactor/eg/testdata/D1.golden
vendored
@ -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
|
||||
}
|
||||
|
4
refactor/eg/testdata/E1.golden
vendored
4
refactor/eg/testdata/E1.golden
vendored
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user