gengo: k8s.io/gengo/parser Index | Files

package parser

import "k8s.io/gengo/parser"

Package parser provides code to parse go files, type-check them, extract the types.

Index

Package Files

doc.go parse.go

type Builder Uses

type Builder struct {

    // If true, include *_test.go
    IncludeTestFiles bool
    // 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 Uses

func New() *Builder

New constructs a new builder.

func (*Builder) AddBuildTags Uses

func (b *Builder) AddBuildTags(tags ...string)

AddBuildTags adds the specified build tags to the parse context.

func (*Builder) AddDir Uses

func (b *Builder) AddDir(dir string) error

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 Uses

func (b *Builder) AddDirRecursive(dir string) error

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 Uses

func (b *Builder) AddDirTo(dir string, u *types.Universe) error

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. Deprecated. Please use AddDirectoryTo.

func (*Builder) AddDirectoryTo Uses

func (b *Builder) AddDirectoryTo(dir string, u *types.Universe) (*types.Package, error)

AddDirectoryTo 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) AddFileForTest Uses

func (b *Builder) AddFileForTest(pkg string, path string, src []byte) error

AddFileForTest adds a file to the set, without verifying that the provided pkg actually exists on disk. The pkg must be of the form "canonical/pkg/path" and the path must be the absolute path to the file. Because this bypasses the normal recursive finding of package dependencies (on disk), test should sort their test files topologically first, so all deps are resolved by the time we need them.

func (*Builder) FindPackages Uses

func (b *Builder) FindPackages() []string

FindPackages fetches a list of the user-imported packages. Note that you need to call b.FindTypes() first.

func (*Builder) FindTypes Uses

func (b *Builder) FindTypes() (types.Universe, error)

FindTypes finalizes the package imports, and searches through all the packages for types.

Package parser imports 15 packages (graph) and is imported by 8 packages. Updated 2019-08-31. Refresh now. Tools for package owners.