I recently created vangen, a static website builder for Go vanity import paths.

I use vanity import paths for all of my Go packages so that I can move the source repository if I need to. My Go packages are not big time projects, but I like that I can defer the decision on where my source code must live and that I get to use short import paths for my own packages.

I considered using github.com/GoogleCloudPlatform/govanityurls which is a small server designed for running on Google App Engine, but this seemed overkill given vanity import paths are just HTML meta tags.

Given that vanity import paths are just HTML meta tags that redirect the go get command and godoc.org to the source code, there’s little need for a server or logic to run on every request, and no need for any complex or substantial infrastructure. vangen generates static HTML files that can be hosted on any web host. e.g. AWS S3, Google Cloud Storage, GitHub Pages, etc.


go get 4d63.com/vangen

Usage: Define a vangen.json file with a domain and a list of repositories.

  "domain": "4d63.com",
  "repositories": [
      "prefix": "optional",
      "subs": [
      "url": "https://github.com/leighmcculloch/go-optional"

Run vangen in the same directory as the file and it will create the static files in a vangen/ directory. The HTML generated will be:

<!DOCTYPE html>
<meta charset="utf-8">
<meta name="go-import" content="4d63.com/optional git https://github.com/leighmcculloch/go-optional">
<meta name="go-source" content="4d63.com/optional https://github.com/leighmcculloch/go-optional https://github.com/leighmcculloch/go-optional/tree/master{/dir} https://github.com/leighmcculloch/go-optional/blob/master{/dir}/{file}#L{line}">

Because of how simple it is to define Go vanity import paths there’s a variety of ways you can do it. You don’t need to use this generator.