Documentation
¶
Index ¶
Constants ¶
const ( // RulesGoRepoName is the canonical name of the rules_go repository. It must // match the workspace name in WORKSPACE. RulesGoRepoName = "io_bazel_rules_go" // RulesGoDefBzlLabel is the canonical label for def.bzl, where all // Go-related rules are defined. RulesGoDefBzlLabel = "@io_bazel_rules_go//go:def.bzl" // DefaultLibName is the name of the default go_library rule in a Go // package directory. It must be consistent to DEFAULT_LIB in go/private/common.bf. DefaultLibName = "go_default_library" // DefaultTestName is a name of an internal test corresponding to // DefaultLibName. It does not need to be consistent to something but it // just needs to be unique in the Bazel package DefaultTestName = "go_default_test" // DefaultXTestName is a name of an external test corresponding to // DefaultLibName. DefaultXTestName = "go_default_xtest" // DefaultProtosName is the name of a filegroup created // whenever the library contains .pb.go files DefaultProtosName = "go_default_library_protos" // DefaultCgoLibName is the name of the default cgo_library rule in a Go package directory. DefaultCgoLibName = "cgo_default_library" )
Variables ¶
var DefaultValidBuildFileNames = []string{"BUILD.bazel", "BUILD"}
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Dirs is a list of absolute paths to directories where Gazelle should run. Dirs []string // RepoRoot is the absolute path to the root directory of the repository. RepoRoot string // ValidBuildFileNames is a list of base names that are considered valid // build files. Some repositories may have files named "BUILD" that are not // used by Bazel and should be ignored. Must contain at least one string. ValidBuildFileNames []string // GenericTags is a set of build constraints that are true on all platforms. // It should not be nil. GenericTags BuildTags // Platforms contains a set of build constraints for each platform. Each set // should include GenericTags. It should not be nil. Platforms PlatformTags // GoPrefix is the portion of the import path for the root of this repository. // This is used to map imports to labels within the repository. GoPrefix string // DepMode determines how imports outside of GoPrefix are resolved. DepMode DependencyMode // KnownImports is a list of imports to add to the external resolver cache. KnownImports []string // StructureMode determines how build files are organized within a project. StructureMode StructureMode }
Config holds information about how Gazelle should run. This is mostly based on command-line arguments.
func (*Config) DefaultBuildFileName ¶
func (*Config) IsValidBuildFileName ¶
func (*Config) PreprocessTags ¶
func (c *Config) PreprocessTags()
PreprocessTags performs some automatic processing on generic and platform-specific tags before they are used to match files.
type DependencyMode ¶
type DependencyMode int
DependencyMode determines how imports of packages outside of the prefix are resolved.
const ( // ExternalMode indicates imports should be resolved to external dependencies // (declared in WORKSPACE). ExternalMode DependencyMode = iota // VendorMode indicates imports should be resolved to libraries in the // vendor directory. VendorMode )
func DependencyModeFromString ¶
func DependencyModeFromString(s string) (DependencyMode, error)
DependencyModeFromString converts a string from the command line to a DependencyMode. Valid strings are "external", "vendor". An error will be returned for an invalid string.
type PlatformTags ¶
PlatformTags is a map from config_setting labels (for example, "@io_bazel_rules_go//go/platform:linux_amd64") to a sets of build tags that are true on each platform (for example, "linux,amd64").
var DefaultPlatformTags PlatformTags
DefaultPlatformTags is the default set of platforms that Gazelle will generate files for. These are the platforms that both Go and Bazel support.
type StructureMode ¶ added in v0.5.4
type StructureMode int
StructureMode determines how build files are organized within a project.
const ( // In HierarchicalMode, one build file is generated per directory. This is // the default mode. HierarchicalMode StructureMode = iota // In FlatMode, one build file is generated for the entire repository. // FlatMode build files can be used with new_git_repository or // new_http_archive. FlatMode )