Documentation ¶
Index ¶
- func AST(fset *token.FileSet, file *ast.File) ([]byte, error)
- func ASTWrite(dest io.Writer, fset *token.FileSet, file *ast.File) error
- func Autogen(data []byte) ([]byte, error)
- func AutogenWrite(dest io.Writer, data []byte) error
- func Format(dest io.Writer, data []byte)
- func FormatReader(dest io.Writer, src io.Reader)
- func Source(src []byte, filename string) ([]byte, error)
- func SourceWrite(dest io.Writer, src []byte, filename string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AST ¶ added in v1.6.0
AST format of given AST
Example ¶
package main import ( "go/parser" "go/token" "io/ioutil" "os" "github.com/sirkon/message" "github.com/sirkon/gosrcfmt" ) func main() { fset := token.NewFileSet() data, err := ioutil.ReadFile("testdata/main.go") if err != nil { message.Fatal(err) } file, err := parser.ParseFile(fset, "testdata/main.go", data, parser.AllErrors|parser.ParseComments) if err != nil { message.Fatal(err) } output, err := gosrcfmt.AST(fset, file) if err != nil { message.Fatal(err) } _, _ = os.Stdout.Write(output) }
Output: // +build !windows package pkg func main() { if true { } }
func AutogenWrite ¶ added in v1.7.0
AutogenWrite writes Autogen output into dest
func FormatReader ¶
FormatReader formats data from src as a go code with gofmt utility Deprecated
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.