Documentation ¶
Index ¶
- func Parse(fset *token.FileSet, target string, src interface{}, mode parser.Mode) (pkgs map[string]*ast.Package, err error)
- func ParseDir(fset *token.FileSet, path string, filter func(os.FileInfo) bool, ...) (pkgs map[string]*ast.Package, first error)
- func ParseFSDir(fset *token.FileSet, fs FileSystem, path string, filter func(os.FileInfo) bool, ...) (pkgs map[string]*ast.Package, first error)
- func ParseFSFile(fset *token.FileSet, fs FileSystem, filename string, src interface{}, ...) (f *ast.File, err error)
- type FileSystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(fset *token.FileSet, target string, src interface{}, mode parser.Mode) (pkgs map[string]*ast.Package, err error)
Parse parses a single Go source file. The target specifies the Go source file. If the file couldn't be read, a nil map and the respective error are returned.
func ParseDir ¶
func ParseDir(fset *token.FileSet, path string, filter func(os.FileInfo) bool, mode parser.Mode) (pkgs map[string]*ast.Package, first error)
ParseDir calls ParseFSDir by passing a local filesystem.
func ParseFSDir ¶
func ParseFSDir(fset *token.FileSet, fs FileSystem, path string, filter func(os.FileInfo) bool, mode parser.Mode) (pkgs map[string]*ast.Package, first error)
ParseFSDir calls ParseFile for all files with names ending in ".go" in the directory specified by path and returns a map of package name -> package AST with all the packages found.
If filter != nil, only the files with os.FileInfo entries passing through the filter (and ending in ".go") are considered. The mode bits are passed to ParseFile unchanged. Position information is recorded in fset, which must not be nil.
If the directory couldn't be read, a nil map and the respective error are returned. If a parse error occurred, a non-nil but incomplete map and the first error encountered are returned.