1
0
mirror of https://github.com/golang/go synced 2024-11-20 06:44:40 -07:00

go/printer: remove "written" result value - is never used

R=r
CC=golang-dev
https://golang.org/cl/5436052
This commit is contained in:
Robert Griesemer 2011-11-22 15:27:10 -08:00
parent a0e54aaffa
commit 4874d14180
5 changed files with 9 additions and 12 deletions

View File

@ -109,7 +109,7 @@ func gofmtFile(f *ast.File) ([]byte, error) {
var buf bytes.Buffer
ast.SortImports(fset, f)
_, err := printConfig.Fprint(&buf, fset, f)
err := printConfig.Fprint(&buf, fset, f)
if err != nil {
return nil, err
}
@ -203,7 +203,7 @@ var gofmtBuf bytes.Buffer
func gofmt(n interface{}) string {
gofmtBuf.Reset()
_, err := printConfig.Fprint(&gofmtBuf, fset, n)
err := printConfig.Fprint(&gofmtBuf, fset, n)
if err != nil {
return "<" + err.Error() + ">"
}

View File

@ -121,7 +121,7 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error
}
var buf bytes.Buffer
_, err = (&printer.Config{printerMode, *tabWidth}).Fprint(&buf, fset, file)
err = (&printer.Config{printerMode, *tabWidth}).Fprint(&buf, fset, file)
if err != nil {
return err
}

View File

@ -20,7 +20,7 @@ import (
var testfile *ast.File
func testprint(out io.Writer, file *ast.File) {
if _, err := (&Config{TabIndent | UseSpaces, 8}).Fprint(out, fset, file); err != nil {
if err := (&Config{TabIndent | UseSpaces, 8}).Fprint(out, fset, file); err != nil {
log.Fatalf("print error: %s", err)
}
}

View File

@ -1000,21 +1000,18 @@ func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node interface{
return
}
// Fprint "pretty-prints" an AST node to output and returns the number
// of bytes written and an error (if any) for a given configuration cfg.
// Fprint "pretty-prints" an AST node to output for a given configuration cfg.
// Position information is interpreted relative to the file set fset.
// The node type must be *ast.File, or assignment-compatible to ast.Expr,
// ast.Decl, ast.Spec, or ast.Stmt.
// Note: The number of bytes written is always 0 and should be ignored.
//
func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node interface{}) (int, error) {
return 0, cfg.fprint(output, fset, node, make(map[ast.Node]int))
func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node interface{}) error {
return cfg.fprint(output, fset, node, make(map[ast.Node]int))
}
// Fprint "pretty-prints" an AST node to output.
// It calls Config.Fprint with default settings.
//
func Fprint(output io.Writer, fset *token.FileSet, node interface{}) error {
_, err := (&Config{Tabwidth: 8}).Fprint(output, fset, node)
return err
return (&Config{Tabwidth: 8}).Fprint(output, fset, node)
}

View File

@ -62,7 +62,7 @@ func runcheck(t *testing.T, source, golden string, mode checkMode) {
// format source
var buf bytes.Buffer
if _, err := cfg.Fprint(&buf, fset, prog); err != nil {
if err := cfg.Fprint(&buf, fset, prog); err != nil {
t.Error(err)
}
res := buf.Bytes()