You may have heard that Golang version 1.13 was released this month. We’re excited for the newest features and want to make you aware of a few changes that may impact your builds. Most of all, we want to let you know some best practices for using these powerful new Golang features with GoCenter.
Go Modules Win
Ever since Go introduced modules in Golang 1.11, the Go community has been busy building up the module ecosystem. Developers have been working with proxies such as GoCenter to download versioned go modules.
With Golang 1.13, support for Go modules is enabled by default, Although new installations of the Go client automatically set a default Google-hosted proxy you can override it and use a Go module proxy of your choice such as GoCenter. Did you know:
- GoCenter now hosts over 260,000 versioned go modules and is still rapidly growing.
- GoCenter can help accelerate your Go application build times.
- GoCenter provides rich data about Go modules through a powerful UI that helps you find the modules you need.
- GoCenter stays up-to-date for Golang and provides innovations of its own.
Best Practices for GoCenter with Golang 1.13
Here’s what you need for GoCenter to work best with Golang 1.13.
GOPROXY for GoCenter
To use GoCenter as your proxy for versioned go modules, set the
GOPROXY environment variable to the GoCenter URL:
If you’re new to Golang you’ve just installed version 1.13, you’ll have to change the
GOPROXY setting from the default to what’s shown above. If you were already using GoCenter, updating to Golang 1.13 won’t change your existing settings, so there’s nothing more you need to do.
New features in Golang 1.13 permit you to specify in
GOPROXY multiple proxies separated by commas, and also a
direct mode to download modules directly from the source. But GoCenter’s automatic inclusion of Go modules means you should not need to use these when proxying with GoCenter.
Checksum DB Support
From version 1.13 of Golang,
go get performs authentication of modules through an auditable checksum database that Google maintains at
sum.golang.org. Installing version 1.13 sets this checksum DB URL by default in the
GOSUMDB environment variable.
GoCenter helps accelerate your builds by proxying
sum.golang.org. If your
GOPROXY is set for GoCenter, you don’t need to change anything — you’re already validating your modules through GoCenter!
Private Go Module Repositories
GoCenter is for proxying Go modules that are shared through a public source repository (e.g., Github). Golang 1.13 has also introduced some environment variables, notably
GOPRIVATE, for bypassing the proxy and checksum validation to download module versions from private repositories. You can read about how to use them in the Golang documentation.
With version 1.13, using the right suffix for your Go modules is very important. The
go command now performs additional validation on the requested version string, and if a module isn’t in compliance with semantic import versioning a
go get will fail. So a pseudo version of your module that loaded without issues before Golang 1.13 may fail now.
Go For More
For more information about GoCenter and to get your questions answered about the Golang 1.13 updates – join our Slack channel! Then continue to explore JFrog GoCenter and be a part of a growing community of Go module authors. Build fast with us and be part of the Liquid Software Revolution!