package parser
import "k8s.io/kubernetes/cmd/libs/go2idl/parser"
Package parser provides code to parse go files, type-check them, extract the types.
Index ¶
- type Builder
- func New() *Builder
- func (b *Builder) AddBuildTags(tags ...string)
- func (b *Builder) AddDir(dir string) error
- func (b *Builder) AddDirRecursive(dir string) error
- func (b *Builder) AddDirTo(dir string, u *types.Universe) error
- func (b *Builder) AddFile(pkg string, path string, src []byte) error
- func (b *Builder) FindPackages() []string
- func (b *Builder) FindTypes() (types.Universe, error)
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder lets you add all the go files in all the packages that you care about, then constructs the type source data.
func New ¶
func New() *Builder
New constructs a new builder.
func (*Builder) AddBuildTags ¶
AddBuildTags adds the specified build tags to the parse context.
func (*Builder) AddDir ¶
AddDir adds an entire directory, scanning it for go files. 'dir' should have a single go package in it. GOPATH, GOROOT, and the location of your go binary (`which go`) will all be searched if dir doesn't literally resolve.
func (*Builder) AddDirRecursive ¶
AddDirRecursive is just like AddDir, but it also recursively adds subdirectories; it returns an error only if the path couldn't be resolved; any directories recursed into without go source are ignored.
func (*Builder) AddDirTo ¶
AddDirTo adds an entire directory to a given Universe. Unlike AddDir, this processes the package immediately, which makes it safe to use from within a generator (rather than just at init time. 'dir' must be a single go package. GOPATH, GOROOT, and the location of your go binary (`which go`) will all be searched if dir doesn't literally resolve.
func (*Builder) AddFile ¶
AddFile adds a file to the set. The pkg must be of the form "canonical/pkg/path" and the path must be the absolute path to the file.
func (*Builder) FindPackages ¶
FindPackages fetches a list of the user-imported packages.
func (*Builder) FindTypes ¶
FindTypes finalizes the package imports, and searches through all the packages for types.
Source Files ¶
doc.go parse.go
- Version
- v1.4.12
- Published
- Apr 20, 2017
- Platform
- js/wasm
- Imports
- 13 packages
- Last checked
- 2 minutes ago –
Tools for package owners.