package build

Import Path
	go/build (on and

Dependency Relation
	imports 22 packages, and imported by 3 packages

Involved Source Files
	d-> doc.go

Exported Type Names

type Context (struct) A Context specifies the supporting context for a build. The build and release tags specify build constraints that should be considered satisfied when processing +build lines. Clients creating a new context may customize BuildTags, which defaults to empty, but it is usually an error to customize ReleaseTags, which defaults to the list of Go releases the current release is compatible with. BuildTags is not set for the Default build Context. In addition to the BuildTags and ReleaseTags, build constraints consider the values of GOARCH and GOOS as satisfied tags. The last element in ReleaseTags is assumed to be the current release. // whether cgo files are included // compiler to assume when computing target paths Dir is the caller's working directory, or the empty string to use the current directory of the running process. In module mode, this is used to locate the main module. If Dir is non-empty, directories passed to Import and ImportDir must be absolute. // target architecture // target operating system // Go path // Go root HasSubdir reports whether dir is lexically a subdirectory of root, perhaps multiple levels below. It does not try to check whether dir exists. If so, HasSubdir sets rel to a slash-separated path that can be joined to root to produce a path equivalent to dir. If HasSubdir is nil, Import uses an implementation built on filepath.EvalSymlinks. The install suffix specifies a suffix to use in the name of the installation directory. By default it is empty, but custom builds that need to keep their outputs separate can set InstallSuffix to do so. For example, when using the race detector, the go command uses InstallSuffix = "race", so that on a Linux/386 system, packages are written to a directory named "linux_386_race" instead of the usual "linux_386". IsAbsPath reports whether path is an absolute path. If IsAbsPath is nil, Import uses filepath.IsAbs. IsDir reports whether the path names a directory. If IsDir is nil, Import calls os.Stat and uses the result's IsDir method. JoinPath joins the sequence of path fragments into a single path. If JoinPath is nil, Import uses filepath.Join. OpenFile opens a file (not a directory) for reading. If OpenFile is nil, Import uses os.Open. ReadDir returns a slice of os.FileInfo, sorted by Name, describing the content of the named directory. If ReadDir is nil, Import uses ioutil.ReadDir. ReleaseTags []string SplitPathList splits the path list into a slice of individual paths. If SplitPathList is nil, Import uses filepath.SplitList. // use files regardless of +build lines, file names Import returns details about the Go package named by the import path, interpreting local import paths relative to the srcDir directory. If the path is a local import path naming a package that can be imported using a standard import path, the returned package will set p.ImportPath to that path. In the directory containing the package, .go, .c, .h, and .s files are considered part of the package except for: - .go files in package documentation - files starting with _ or . (likely editor temporary files) - files with build constraints not satisfied by the context If an error occurs, Import returns a non-nil error and a non-nil *Package containing partial information. ImportDir is like Import but processes the Go package found in the named directory. MatchFile reports whether the file with the given name in the given directory matches the context and would be included in a Package created by ImportDir of that directory. MatchFile considers the name of the file and may use ctxt.OpenFile to read some or all of the file's content. SrcDirs returns a list of package source root directories. It draws from the current Go root and Go path but omits directories that do not exist. func go/internal/srcimporter.New(ctxt *Context, fset *token.FileSet, packages map[string]*types.Package) *srcimporter.Importer var Default
type ImportMode uint An ImportMode controls the behavior of the Import method. func Import(path, srcDir string, mode ImportMode) (*Package, error) func ImportDir(dir string, mode ImportMode) (*Package, error) func (*Context).Import(path string, srcDir string, mode ImportMode) (*Package, error) func (*Context).ImportDir(dir string, mode ImportMode) (*Package, error) const AllowBinary const FindOnly const IgnoreVendor const ImportComment
type MultiplePackageError (struct) MultiplePackageError describes a directory containing multiple buildable Go source files for multiple packages. // directory containing files // corresponding files: Files[i] declares package Packages[i] // package names found (*T) Error() string *T : error
type NoGoError (struct) NoGoError is the error used by Import to describe a directory containing no buildable Go source files. (It may still contain test files, files hidden by build tags, and so on.) Dir string (*T) Error() string *T : error
type Package (struct) A Package describes the Go package found in a directory. // tags that can influence file selection in this directory // command install directory ("" if unknown) // cannot be rebuilt from source (has //go:binary-only-package comment) // .c source files // .cc, .cpp and .cxx source files Cgo directives // Cgo CFLAGS directives // Cgo CPPFLAGS directives // Cgo CXXFLAGS directives // Cgo FFLAGS directives // .go source files that import "C" // Cgo LDFLAGS directives // Cgo pkg-config directives // this directory shadows Dir in $GOPATH // directory containing package sources // documentation synopsis // .f, .F, .for and .f90 Fortran source files Source files // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) // package found in Go root // .h, .hh, .hpp and .hxx source files // .go source files ignored for this build // path in import comment on package statement // import path of package ("" if unknown) // line information for Imports Dependency information // import paths from GoFiles, CgoFiles // .go source files with detected problems (parse error, wrong package name, and so on) // .m (Objective-C) source files // package name // installed .a file // package install root directory ("" if unknown) // architecture dependent install root directory ("" if unknown) // root of Go tree where this package lives // .s source files // package source root directory ("" if unknown) // .swigcxx files // .swig files // .syso system object files to add to archive Test information // _test.go files in package // line information for TestImports // import paths from TestGoFiles // _test.go files outside package // line information for XTestImports // import paths from XTestGoFiles IsCommand reports whether the package is considered a command to be installed (not just a library). Packages named "main" are treated as commands. func Import(path, srcDir string, mode ImportMode) (*Package, error) func ImportDir(dir string, mode ImportMode) (*Package, error) func (*Context).Import(path string, srcDir string, mode ImportMode) (*Package, error) func (*Context).ImportDir(dir string, mode ImportMode) (*Package, error)
Exported Values
const AllowBinary ImportMode = 2 If AllowBinary is set, Import can be satisfied by a compiled package object without corresponding sources. Deprecated: The supported way to create a compiled-only package is to write source code containing a //go:binary-only-package comment at the top of the file. Such a package will be recognized regardless of this flag setting (because it has source code) and will have BinaryOnly set to true in the returned Package.
func ArchChar(goarch string) (string, error) ArchChar returns "?" and an error. In earlier versions of Go, the returned string was used to derive the compiler and linker tool names, the default object file suffix, and the default linker output name. As of Go 1.5, those strings no longer vary by architecture; they are compile, link, .o, and a.out, respectively.
var Default Context Default is the default Context for builds. It uses the GOARCH, GOOS, GOROOT, and GOPATH environment variables if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
const FindOnly ImportMode = 1 If FindOnly is set, Import stops after locating the directory that should contain the sources for a package. It does not read any files in the directory.
const IgnoreVendor ImportMode = 8 By default, Import searches vendor directories that apply in the given source directory before searching the GOROOT and GOPATH roots. If an Import finds and returns a package using a vendor directory, the resulting ImportPath is the complete path to the package, including the path elements leading up to and including "vendor". For example, if Import("y", "x/subdir", 0) finds "x/vendor/y", the returned package's ImportPath is "x/vendor/y", not plain "y". See for more information. Setting IgnoreVendor ignores vendor directories. In contrast to the package's ImportPath, the returned package's Imports, TestImports, and XTestImports are always the exact import paths from the source files: Import makes no attempt to resolve or check those paths.
func Import(path, srcDir string, mode ImportMode) (*Package, error) Import is shorthand for Default.Import.
const ImportComment ImportMode = 4 If ImportComment is set, parse import comments on package statements. Import returns an error if it finds a comment it cannot understand or finds conflicting comments in multiple source files. See for more information.
func ImportDir(dir string, mode ImportMode) (*Package, error) ImportDir is shorthand for Default.ImportDir.
func IsLocalImport(path string) bool IsLocalImport reports whether the import path is a local import path, like ".", "..", "./foo", or "../foo".
var ToolDir string ToolDir is the directory containing build tools.