mirror of https://github.com/golang/go.git
go/go2go: add line comments to rewritten files
Change-Id: I6fe3de668381d89131825ba00cc202f49c7971cf
This commit is contained in:
parent
f95754ecff
commit
10c3db1727
|
|
@ -8,13 +8,18 @@ import (
|
|||
"bufio"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/printer"
|
||||
"go/token"
|
||||
"path/filepath"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var config = printer.Config{
|
||||
Mode: printer.UseSpaces | printer.TabIndent | printer.SourcePos,
|
||||
Tabwidth: 8,
|
||||
}
|
||||
|
||||
// rewrite rewrites the contents of one file.
|
||||
func rewrite(dir string, fset *token.FileSet, filename string, ast *ast.File) (err error) {
|
||||
filename = filepath.Base(filename)
|
||||
|
|
@ -37,5 +42,5 @@ func rewrite(dir string, fset *token.FileSet, filename string, ast *ast.File) (e
|
|||
}()
|
||||
fmt.Fprintln(w, rewritePrefix)
|
||||
|
||||
return format.Node(w, fset, ast)
|
||||
return config.Fprint(w, fset, ast)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue