`go get` on your domain

22 September 2016

I’m currently migrating my Github projects to the excellent self-hosted Gogs Gitea service at https://git.maze.io/.

Playing with the excellent gopkg.in service, I figured it would be awesome to use maze.io as the primary name space for the packages I’m building. As a start I setup a go organiation, https://git.maze.io/go.


At first I played with go-import-redirector which serves as a simple metadata provider for the go get command. Its usage is fairly straight forward:

go-import-redirector [-addr address] [-vcs vcs] [-parts parts] <import> <repo>

So, in order to serve up my go organisation’s repository on the landing page of the maze.io domain, I can simply run:

go-import-redirector -addr / https://git.maze.io/go

To make this work in conjunction with the other content hosted on my site, we use the following piece of nginx configuration:

upstream go-import-redirector {

server {
  server_name maze.io

  # ... other definitions ...

  location / {
    proxy_set_header Host $host;
    if ($args ~ "go-get") {
      proxy_pass http://go-import-redirector;

    # ... default location configuration ...

Let’s test go get:

% go get -v maze.io/phi
Fetching https://maze.io/phi?go-get=1
Parsing meta tags from https://maze.io/phi?go-get=1 (status code 200)
get "maze.io/phi": found meta tag main.metaImport{Prefix:"maze.io/phi", VCS:"git", RepoRoot:"https://git.maze.io/go/phi"} at https://maze.io/phi?go-get=1
maze.io/phi (download)

It worked! And as a bonus, the supervisord program definition:

command         = go-import-redirector -addr / https://git.maze.io/go
directory       = /tmp
priority        = 100
startretries    = 99999999
stdout_logfile  = /var/log/go-import-redirector.log
redirect_stderr = true

nota bene: The Go namespace is actually located at maze.io/x/….