Skip to content

Use a custom domain in your Go import path

License

Notifications You must be signed in to change notification settings

mlcdf/vanity-imports

Repository files navigation

vanity-imports

test

Generate HTML pages that allow you to set "custom" or "vanity" import paths for your Go packages using the go-import meta tag (read the specs).

For example, this package import path is go.mlcdf.fr/vanity-imports (instead of github.com/mlcdf/vanity-imports).

Highlights

  • Painless to host: it's only static files
  • Designed to be used in a CI environment: ship as single binary with no OS dependencies
  • Easy to configure and extend via a single TOML configuration file
  • Use your own template for the index and the repo pages.

Install

  • From GitHub releases: download the binary corresponding to your OS and architecture.
  • From source (make sure $GOPATH/bin is in your $PATH):
go get go.mlcdf.fr/vanity-imports

Usage

Usage:
    vanity-imports [option]

Options:
    --init                  creates a sample .vanity-imports.toml config file
    -c, --config CONFIG     path to the config. Defaults to .vanity-imports.toml
    -V, --version           print version

First, create a config file.

vanity-imports --init

Generate the HTML pages

vanity-imports

Upload the content of the dist directory to your web server or your favorite static hosting service such as GitHub Pages, OVHcloud Web Hosting or Netlify.

Configuration format

Format for the .vanity-imports.toml file.

domain = "go.mlcdf.fr" # required
output = "output" # default to dist
repo_template = """<golang template>""" # override the default template for the repo page
index_template = """<golang template>""" # override the default template for the index page

[index]
description = ""
extra_head = "" # extra html tags appended to the head
title = "" # required

[repos]

[repos."/dyndns"] # domain + "/dyndns will be your package import path
repo = "https://github.com/mlcdf/dyndns/" # required. Url to the source repository
vcs = "git"

Example usage

Check out the netlify branch to find the code behind https://go.mlcdf.fr/.

Development

Generate the pages

go run .

Regenerate the pages on file changes and start a web server on http://localhost:3000.

./scripts/dev.sh

Run the tests

go test ./...

License

MIT