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
}
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() + ">"
}
}
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
}
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)
}
}
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)
}