This guide will walk you through the process of creating a Go Modules project, pushing it to Gemfury, and then importing it as a dependency.
Historically, there are a number of ways to create and distribute Go projects. This guide and our service focuses on Go Modules. And for simplicity, we will work outside of $GOPATH.
Before you get started, be sure you have the following:
Local Go installation (1.
To get started, create a new directory and initialize your module with go mod init:
$ mkdir gorepo && cd gorepo $ go mod init git.fury.io/example/gorepo This command will create an initial go.mod file to describe your project. The file will contain the project’s name and other module dependencies. Be sure to commit go.mod and the related go.sum checksum file into your project’s Git repo.
You may now structure your module as a single root package, and/or multiple packages in a subdirectory structure:
Now that you have the structure of your Go module in place, you can push it into your Gemfury account.
Git push To upload a module to your account, use the Git builder:
# Initial one-time setup $ git remote add fury https://git.fury.io/USERNAME/gorepo.git # Push to build a new version $ git push fury master Username for 'https://git.fury.io': <Your personal username> Password for 'https://firstname.lastname@example.org': <Your personal password> The USERNAME in the path of your git.
Go toolkit 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 Gemfury 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/.