Commit 4874d141 authored by Robert Griesemer's avatar Robert Griesemer

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

R=r
CC=golang-dev
https://golang.org/cl/5436052
parent a0e54aaf
......@@ -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() + ">"
}
......
......@@ -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
}
......
......@@ -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)
}
}
......
......@@ -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)
}
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment