head 1.1; access; symbols; locks strick:1.1; strict; comment @# @; 1.1 date 2012.10.01.07.47.09; author strick; state Exp; branches; next ; desc @@ 1.1 log @/dev/null @ text @package main import "fmt" import "go/parser" import "go/token" func p(x ...interface{}) { for _, e := range x { fmt.Printf("## %#v ", e) } fmt.Println() } func main() { fset := token.NewFileSet() // positions are relative to fset // Parse the file containing this very example // but stop after processing the imports. f, err := parser.ParseFile(fset, "a.go", nil, parser.Trace /*| parser.ParseComments */) if err != nil { fmt.Println(err) return } p("f", f) // Print the imports from the file's AST. for _, s := range f.Imports { fmt.Println(s.Path.Value) p(s) p(s.Path) p(s.Path.Value) } } @