guide-go

Introduction

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.13+) Gemfury account Although we like to use the term “package” at Gemfury to describe top-level project archives, the Go community prefers the term “module”. 

Creating a Go module

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: 

Upload your Go module

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://user@git.fury.io': <Your personal password> The USERNAME in the path of your git. 

Install packages with Go

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/.