go_deps

TAG CLASSES

archive_override

Override the default source location on a given Go module in this extension.

Attributes

NameDescriptionTypeMandatoryDefault
patch_stripThe number of leading path segments to be stripped from the file name in the patches.Integeroptional0
patchesA list of patches to apply to the repository after gazelle runs.List of labelsoptional[]
pathThe Go module path for the repository to be overridden.

This module path must be defined by other tags in this extension within this Bazel module.
Stringrequired
sha256If the repository is downloaded via HTTP (urls is set), this is the SHA-256 sum of the downloaded archive. When set, Bazel will verify the archive against this sum before extracting it.Stringoptional""
strip_prefixIf the repository is downloaded via HTTP (urls is set), this is a directory prefix to strip. See [http_archive.strip_prefix].Stringoptional""
urlsA list of HTTP(S) URLs where an archive containing the project can be downloaded. Bazel will attempt to download from the first URL; the others are mirrors.List of stringsoptional[]

config

Configures the general behavior of the go_deps extension.

Only the root module's config tag is used.

Attributes

NameDescriptionTypeMandatoryDefault
check_direct_dependenciesThe way in which warnings about version mismatches for direct dependencies and Go modules that are also Bazel modules are reported.Stringoptional""
debug_modeWhether or not to print stdout and stderr messages from gazelleBooleanoptionalFalse
go_envThe environment variables to use when fetching Go dependencies or running the @rules_go//go tool.Dictionary: String -> Stringoptional{}

from_file

Imports Go module dependencies from either a go.mod file or a go.work file.

All direct and indirect dependencies of the specified module will be imported, but only direct dependencies should be imported into the scope of the using module via use_repo calls. Use bazel mod tidy to update these calls automatically.

Attributes

NameDescriptionTypeMandatoryDefault
fail_on_version_conflictFail if duplicate modules have different versionsBooleanoptionalTrue
go_mod-LabeloptionalNone
go_work-LabeloptionalNone

gazelle_override

Override Gazelle's behavior on a given Go module defined by other tags in this extension.

Attributes

NameDescriptionTypeMandatoryDefault
build_extra_argsA list of additional command line arguments to pass to Gazelle when generating build files.List of stringsoptional[]
build_file_generationOne of "auto", "on" (default), "off", "clean".

Whether Gazelle should generate build files for the Go module.

Although “auto” is the default globally for build_file_generation, if a "gazelle_override" or "gazelle_default_attributes" tag is present for a Go module, the "build_file_generation" attribute will default to “on” since these tags indicate the presence of "directives" or "build_extra_args".

In "auto" mode, Gazelle will run if there is no build file in the Go module's root directory.

In "clean" mode, Gazelle will first remove any existing build files.
Stringoptional"on"
directivesGazelle configuration directives to use for this Go module's external repository.

Each directive uses the same format as those that Gazelle accepts as comments in Bazel source files, with the directive name followed by optional arguments separated by whitespace.
List of stringsoptional[]
pathThe Go module path for the repository to be overridden.

This module path must be defined by other tags in this extension within this Bazel module.
Stringrequired

gazelle_default_attributes

Override Gazelle's default attribute values for all modules in this extension.

Attributes

NameDescriptionTypeMandatoryDefault
build_extra_argsA list of additional command line arguments to pass to Gazelle when generating build files.List of stringsoptional[]
build_file_generationOne of "auto", "on" (default), "off", "clean".

Whether Gazelle should generate build files for the Go module.

Although “auto” is the default globally for build_file_generation, if a "gazelle_override" or "gazelle_default_attributes" tag is present for a Go module, the "build_file_generation" attribute will default to “on” since these tags indicate the presence of "directives" or "build_extra_args".

In "auto" mode, Gazelle will run if there is no build file in the Go module's root directory.

In "clean" mode, Gazelle will first remove any existing build files.
Stringoptional"on"
directivesGazelle configuration directives to use for this Go module's external repository.

Each directive uses the same format as those that Gazelle accepts as comments in Bazel source files, with the directive name followed by optional arguments separated by whitespace.
List of stringsoptional[]

module

Declare a single Go module dependency. Prefer using from_file instead.

Attributes

NameDescriptionTypeMandatoryDefault
build_file_proto_modeRemoved, do not useStringoptional""
build_naming_conventionRemoved, do not useStringoptional""
indirectWhether this Go module is an indirect dependency.BooleanoptionalFalse
local_pathFor when a module is replaced by one residing in a local directory pathStringoptional""
pathThe module path.Stringrequired
sum-Stringoptional""
version-Stringrequired

module_override

Apply patches to a given Go module defined by other tags in this extension.

Attributes

NameDescriptionTypeMandatoryDefault
patch_stripThe number of leading path segments to be stripped from the file name in the patches.Integeroptional0
patchesA list of patches to apply to the repository after gazelle runs.List of labelsoptional[]
pathThe Go module path for the repository to be overridden.

This module path must be defined by other tags in this extension within this Bazel module.
Stringrequired