Using private Go Modules βeta

Once you have signed up for a Gemfury account, you can upload and install Go packages.

Your secret Repository URL

The secret repository URL is the Go Modules proxy URL for your Gemfury account and packages. Do not share this URL to keep your account private. Your Repo-URL has the following format:

https://TOKEN@go.fury.io/USERNAME/

Uploading packages by Go

We made a guide about creating a Go package and you can also learn from the Go blog website. Once you have the module, you can use Git to push your module to your Gemfury account.

To upload a module to your account, use the Git builder:

# Initial one-time setup
$ git remote add fury https://git.fury.io/USERNAME/PACKAGE-NAME.git

# Push to build a new version
$ git push fury master
Username for 'https://git.fury.io': <Your personal username>
Password for 'https://user@git.fury.io': <Your personal password>

The USERNAME in the path of your git.fury.io repository URL is the destination of the build, however, the username and password for authentication are your account credentials. Usually the former is your team account, and the latter is a personal one.

Versioning

Go Modules are versioned with Semantic Versioning scheme derived from the tags of your Git repo. To release a new version, create a tag and push it:

$ git tag v1.1.8
$ git push --tags fury master

Git builder always builds the tip of master. If the tip is not tagged, Gemfury will automatically generate a prerelease version of your package.

Setting up Go with Gemfury

Go uses a central proxy to collect a project’s dependencies. By default, it is configured to the public proxy run by Go’s patron-company (Google).

When you reconfigure your Go tooling to use Gemfury, our blending-proxy will first look for named packages in your account with the fallback to the public proxy for packages not found there.1

Set the following environment variables to configure Go to use Gemfury. This can be done in your terminal before running go or in a start-up shell script like $HOME/.profile:

$ export GOPROXY=https://TOKEN@go-proxy.fury.io/USERNAME/
$ export GOPRIVATE="git.fury.io/USERNAME/*"
$ export GONOPROXY=none

Once you have this configuration in place, start your build:

$ go build ./...

Please note that GOPRIVATE specifies the match pattern for the names of your private modules, and does not have to be a “fury.io” URL. Please adjust it to match the names of modules you upload to Gemfury.

Public packages

If you are only accessing public packages in your Gemfury account, you do not need to specify the token in the proxy URL.

Fetching directly using the Git Builder’s URL

If you have specified your module dependencies using the Git builder URL, you may allow Go to directly fetch the module from your account.

If your go.mod specified the dependency as:

require git.fury.io/USERNAME/PACKAGE v1.0.0

You may choose to keep your GOPROXY environment variable unset or use the default public proxy, since Go supports directly connnecting to the source control’s server.

With this configuration, you may start the build:

$ go build ./...

For private packages, you can specify the credentials in your ~/.netrc file, which Go will use if specified:

machine git.fury.io
  login     <personal-email>
  password  <password-or-api-token>

βeta notes

Currently, Go Modules support is in Beta. Please contact us if you encounter difficulties in using it.


  1. Go does not support splitting public and private requests between two proxies. ↩︎