Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


a request redirector that is dedicated for

Design Purpose

The current redir implementation talks to a redis data store for PV/UV counting, as well as short alias storage. In the booting phase, it will read REDIR_CONF from environment variable to identify configuration file (default: ./config.yml).

redir is designed for the following purpose: serve two major redirectors /s and /x (at the moment).

1. Redirect to the pkg's actual VCS.

This is based on the go get vanity import path convention. With this feature, all packages issued by requires to use import path. That is saying, any pkg will be redirected to if exist. The website itself will redirect the request to

There is a reserved ping router for debugging purpose /x/.ping which will give you a pong.

2. Redirect and

The served alias can be allocated by members. The current approach is to use redir command on the server. Here is the overview of its usage:

$ redir
usage: redir [-s] [-f <file>] [-op <operator> -a <alias> -l <link>]
  -a string
        alias for a new link
  -f string
        import aliases from a YAML file
  -l string
        actual link for the alias, optional for delete/fetch
  -op string
        operators, create/update/delete/fetch (default "create")
  -s    run redir service
redir -s                  run the redir service
redir -f ./import.yml     import aliases from a file
redir -a alias -l link    allocate new short link if possible
redir -l link             allocate a random alias for the given link if possible
redir -op fetch -a alias  fetch alias information

For the command line usage, one only needs to use -a, -l, and -op if needed. The command will talk to the Redis data store and issue a new allocated alias. For instance, the following command:

$ redir -a changkun -l

creates a new alias under

If the -a is not provided, then redir command will generate a random string as an alias, but the link can only be accessed under /r/alias. For instance:

$ redir -l

creates a new alias under

Import from a YAML file is also possible, for instance:

$ redir -f import.yml

The aliases are either imported as a new alias or updated for an existing alias.

Moreover, it is possible to visit /s or /r directly listing all exist aliases under


Makefile defines different ways to build the service:

$ make       # build native binary
$ make run   # assume your local redis is running
$ make build # build docker images
$ make up    # run via docker-compose
$ make down  # remove compose stuff
$ make clean # cleanup


private projects go get failure

  1. make sure you are a member of
  2. add ssh public key to your account
  3. git config --global url."".insteadOf ""
  4. add export to your bash profile (e.g. .zshrc).


MIT © The Initiative Authors