Created
September 6, 2018 17:47
-
-
Save astrotars/234cc8ff0aa75067c22607d633d2e1f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"go/ast" | |
"go/parser" | |
"go/token" | |
"log" | |
) | |
func main() { | |
src := []byte(`package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello, world!") | |
} | |
`) | |
fset := token.NewFileSet() | |
file, err := parser.ParseFile(fset, "", src, 0) | |
if err != nil { | |
log.Fatal(err) | |
} | |
ast.Print(fset, file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment