Documentation ¶
Overview ¶
Package golang provides support for Go and Go proto rules. It generates go_library, go_binary, go_test, and go_proto_library rules.
Configuration ¶
Go rules support the flags -build_tags, -go_prefix, and -external. They also support the directives # gazelle:build_tags, # gazelle:prefix, and # gazelle:importmap_prefix. See https://github.com/bazelbuild/bazel-gazelle/blob/master/README.rst#directives for information on these.
Rule generation ¶
Currently, Gazelle generates rules for one Go package per directory. In general, we aim to support Go code which is compatible with "go build". If there are no buildable packages, Gazelle will delete existing rules with default names. If there are multiple packages, Gazelle will pick one that matches the directory name or will print an error if no such package is found.
Gazelle names library and test rules somewhat oddly: go_default_library, and go_default_test. This is for historic reasons: before the importpath attribute was mandatory, import paths were inferred from label names. Even if we never support multiple packages in the future (we should), we should migrate away from this because it's surprising. Libraries should generally be named after their directories.
Dependency resolution ¶
Go libraries are indexed by their importpath attribute. Gazelle attempts to resolve libraries by import path using the index, filtered using the vendoring algorithm. If an import doesn't match any known library, Gazelle guesses a name for it, locally (if the import path is under the current prefix), or in an external repository or vendor directory (depending on external mode).
Gazelle has special cases for import paths associated with proto Well Known Types and Google APIs. rules_go declares canonical rules for these.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLanguage ¶
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
gen_std_package_list reads a text file containing a list of packages (one per line) and generates a .go file containing a set of package names.
|
gen_std_package_list reads a text file containing a list of packages (one per line) and generates a .go file containing a set of package names. |