tree: f3eda12962782bc4bb67e111e9555de6d81732cc [path history] [tgz]
  1. .gcloudignore
  2. app.yaml
  3. CONTRIBUTING.md
  4. go.mod
  5. go.sum
  6. handler.go
  7. handler_test.go
  8. LICENSE
  9. main.go
  10. README.fuchsia
  11. README.md
  12. vanity.yaml
third_party/govanityurls/README.md

Go Vanity URLs

Go Vanity URLs is a simple Go server that allows you to set custom import paths for your Go packages. It also can run on Google App Engine.

Quickstart

Install and run the binary:

$ go get -u github.com/GoogleCloudPlatform/govanityurls
$ # update vanity.yaml
$ govanityurls
$ # open http://localhost:8080

Google App Engine

Install gcloud and install Go App Engine component:

$ gcloud components install app-engine-go

Setup a custom domain for your app.

Get the application:

git clone https://github.com/GoogleCloudPlatform/govanityurls
cd govanityurls

Edit vanity.yaml to add any number of git repos. E.g., customdomain.com/portmidi will serve the https://github.com/rakyll/portmidi repo.

paths:
  /portmidi:
    repo: https://github.com/rakyll/portmidi

You can add as many rules as you wish.

Deploy the app:

$ gcloud app deploy

That's it! You can use go get to get the package from your custom domain.

$ go get customdomain.com/portmidi

Running in other environments

You can also deploy this as an App Engine Flexible app by changing the app.yaml file:

runtime: go
env: flex

This project is a normal Go HTTP server, so you can also incorporate the handler into larger Go servers.

Configuration File

host: example.com
cache_max_age: 3600
paths:
  /foo:
    repo: https://github.com/example/foo
    display: "https://github.com/example/foo https://github.com/example/foo/tree/master{/dir} https://github.com/example/foo/blob/master{/dir}/{file}#L{line}"
    vcs: git

Path Configuration