Documentation
¶
Overview ¶
Package loader loads Go packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlazeLoader ¶
type BlazeLoader struct {
// contains filtered or unexported fields
}
func NewBlazeLoader ¶
func (*BlazeLoader) Close ¶
func (l *BlazeLoader) Close(context.Context) error
Close frees all resources that NewBlazeLoader() created. The BlazeLoader must not be used afterwards.
func (*BlazeLoader) LoadPackages ¶
func (l *BlazeLoader) LoadPackages(ctx context.Context, targets []*Target, res chan LoadResult)
LoadPackage loads a batch of Go packages.
type File ¶
type File struct { // Parsed file. AST *ast.File Path string // For go_test targets, this field indicates whether the file belongs to the // test code itself (one or more _test.go files), or whether the file // belongs to the package-under-test (via the go_test target’s library // attribute). // // For other targets (go_binary or go_library), this field is always false. LibraryUnderTest bool // Source code from the file. Code string // True if the file was generated (go_embed_data, genrule, etc.). Generated bool }
File represents a single file in a loaded package.
type LoadResult ¶
LoadResult represents the result of loading an individual target. The Target field is always set. If something went wrong, Err is non-nil and Package is nil. Otherwise, Err is nil and Package is non-nil.
type Loader ¶
type Loader interface { // LoadPackages loads a batch of Go packages. // // The method does not return a slice of results, but instead writes each // result to the specified result channel as the result arrives. This allows // for concurrency with loaders that support it, like the Compilations // Bigtable loader (processing results while the load is still ongoing). LoadPackages(context.Context, []*Target, chan LoadResult) Close(context.Context) error }
Loader loads Go packages.
type Package ¶
type Package struct { Files []*File // Files in the package. Fileset *token.FileSet // For translating between positions and locations in files. TypeInfo *types.Info // Type information for the package (e.g. object identity, identifier uses/declarations, expression types). TypePkg *types.Package // Describes the package (e.g. import objects, package scope). }
Package represents a loaded Go package.
type Target ¶
type Target struct { // ID is an opaque identifier for the package when using the packages loader. ID string // Testonly indicates that this package should be considered test code. This // attribute needs to be passed in because go/packages does not have the // concept of test only code, only Blaze does. Testonly bool LibrarySrcs map[string]bool }
Target represents a package to be loaded. It is identified by the opaque ID field, which is interpreted by the loader (which, in turn, delegates to the gopackagesdriver).