Vanity Import Paths for Golang Packages

When a request includes go-get=1, the getvain service responds with a "go-import" <meta> tag, allowing go get to check code out of a version control system.

By default, getvain helps go get find packages via fossil, such that go get finds a <meta> tag content " fossil".

The behavior can be modified with flags:

  -addr string
		listen on address, i.e. "localhost:8080"; if omitted, serve CGI
  -domain string
		domain where source code is found
  -strip uint
		strip text from start of path, i.e. -strip=1 to make /src/foo become repository foo
  -suffix string
		append suffix to repository name
  -v    verbose log
  -vcs string
		version control system (default "fossil")

Example: fossil via CGI

If fossil is configured to serve multiple repositories over CGI, you may find go get requests failing. Configuring fossil to serve a "go-import" meta tag can solve the problem, but may be difficult to configure for nested packages (i.e. go get Instead of configuring fossil to serve the <meta> tag, consider wrapping the fossil CGI script in a conditional script:

# while not ideal to launch this script process with every request, we'd be launcing fossil anyway...
if [ "$QUERY_STRING" = "go-get=1" ]

The result is that getvain serves requests from go-get, while fossil serves other requests.

CGI usage

When getvain is run as a CGI script, parameters can be placed in the cgi-bin file. For example, the equivalent of getvain -domain -strip 0 -v becomes

-strip 0