Compatibility
rules_go
0.19.0 or later is now required. Older versions are not supported but may still work, depending on what features are needed.
General changes
gazelle update-repos
now supports the flag-to_macro=file.bzl%macro
. Instead of writing new repository rules to WORKSPACE, rules will be written to a function in a separate .bzl file. This helps keep related rules together. Thanks to @blico!- The directive
# gazelle:repository_macro file.bzl%macro
may be used in WORKSPACE to declare a macro generated with the above flag.gazelle update-repos
will automatically update rules declared in the named macros instead of adding them to WORKSPACE. The directive may be repeated for multiple macros.gazelle fix
andgazelle update
will also read workspaces declared in these macros to find known repository roots and names. Thanks again to @blico! - The directive
# gazelle:exclude .
may now be written to skip updating the current directory and subdirectories. Previously,exclude
only applied to files and subdirectories.
Go changes
go_repository
can now download modules. To download a module, set theversion
andsum
attributes instead ofurls
(for HTTP) orcommit
ortag
(for VCS downloads).go_repository
will download and verify the specified module withgo mod download
. The environment variablesGOPROXY
,GOPRIVATE
,GONOPROXY
,GOSUMDB
, andGONOSUMDB
are observed, so be sure to set these for private modules when using go1.13 or later.gazelle update-repos <path>
will add or updatego_repository
rules in module mode.gazelle update-repos -from_file=go.mod
will also add or update rules in module mode.- Refactored infrastructure behind
go_repository
. There are now separate tools and cache workspaces. Modules are downloaded into the cache. When Gazelle is updated, it should not be necessary to re-download modules unless the implementation of the cache changes. The environment variableGO_REPOSITORY_USE_HOST_CACHE
may be set to1
to use$GOPATH/pkg/mod
as a module cache instead of the cache workspace. go_repository
now provides areplace
attribute in module mode, analogous toreplace
in a go.mod file. Theversion
andsum
attributes are used on the replacement, but build files will be generated with theimportpath
of the original module.gazelle update-repos -from-file=go.mod
will addreplace
attributes automatically (thanks to @bigkraig!).gazelle update-repos
now supports the flag-prune
, which may be used with-from_file
. When enabled, Gazelle will removego_repository
rules that no longer have equivalent repos in go.mod or Gopkg.lock. Thanks to @blico!- When run by
go_repository
, Gazelle now supports minimal module compatibility. For v2+ modules, Gazelle will generateimportpath_aliases
attributes sogo_libraries
may be imported without the semantic import version suffix by non-modularized packages.
Proto changes
- Updated table of known proto import paths for consistency with rules_go 0.19.0.