diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/cmd/fix/main.go | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/cmd/fix/main.go')
-rw-r--r-- | src/cmd/fix/main.go | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/cmd/fix/main.go b/src/cmd/fix/main.go index b151408d7..dc10d6beb 100644 --- a/src/cmd/fix/main.go +++ b/src/cmd/fix/main.go @@ -9,8 +9,8 @@ import ( "flag" "fmt" "go/ast" + "go/format" "go/parser" - "go/printer" "go/scanner" "go/token" "io/ioutil" @@ -97,23 +97,11 @@ func main() { os.Exit(exitCode) } -const ( - tabWidth = 8 - parserMode = parser.ParseComments - printerMode = printer.TabIndent | printer.UseSpaces -) - -var printConfig = &printer.Config{ - Mode: printerMode, - Tabwidth: tabWidth, -} +const parserMode = parser.ParseComments func gofmtFile(f *ast.File) ([]byte, error) { var buf bytes.Buffer - - ast.SortImports(fset, f) - err := printConfig.Fprint(&buf, fset, f) - if err != nil { + if err := format.Node(&buf, fset, f); err != nil { return nil, err } return buf.Bytes(), nil @@ -211,8 +199,7 @@ var gofmtBuf bytes.Buffer func gofmt(n interface{}) string { gofmtBuf.Reset() - err := printConfig.Fprint(&gofmtBuf, fset, n) - if err != nil { + if err := format.Node(&gofmtBuf, fset, n); err != nil { return "<" + err.Error() + ">" } return gofmtBuf.String() |