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" "bytes"
"fmt" "fmt"
"go/ast" "go/ast"
"go/format"
"go/printer" "go/printer"
"go/token" "go/token"
"os" "os"
@ -288,7 +289,7 @@ func WriteAST(fset *token.FileSet, filename string, f *ast.File) (err error) {
err = err2 // prefer earlier error err = err2 // prefer earlier error
} }
}() }()
return printer.Fprint(fh, fset, f) return format.Node(fh, fset, f)
} }
// -- utilities -------------------------------------------------------- // -- utilities --------------------------------------------------------

View File

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

View File

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

View File

@ -3,9 +3,9 @@
package E1 package E1
import ( import (
"fmt"
"log" "log"
"os" "os"
"fmt"
) )
func example() { func example() {