package main import ( "fmt" "go/ast" ) func parseFile(f *ast.File) { loc := f.Name.String() for _, d := range f.Decls { switch d := d.(type) { case *ast.GenDecl: parseGenDecl(loc, d) case *ast.FuncDecl: parseFuncDecl(loc, d) default: fmt.Printf("Unknown decl type in %s: %T\n", loc, d) } } } func parseTypeSpec(loc string, s *ast.TypeSpec) { fmt.Printf("%s/typeSpec\n", loc) }