github.com/lheiskan/zebrapack@v4.1.1-0.20181107023619-e955d028f9bf+incompatible/cmd/addzid/pp.go (about)

     1  package main
     2  
     3  import (
     4  	"go/ast"
     5  	"go/printer"
     6  	"go/token"
     7  	"io"
     8  )
     9  
    10  // PrettyPrint out the go source file we read in.
    11  func (x *Extractor) PrettyPrint(output io.Writer, fileSet *token.FileSet, astfile *ast.File) error {
    12  
    13  	printConfig := &printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 4}
    14  
    15  	err := printConfig.Fprint(output, fileSet, astfile)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  	return nil
    20  }