Inspired by Mathias Bynens' PHP URL Shortener, and triggered by a wish to learn Go, I wanted to try and see if I could build an URL shortener in Go.
- Redirect to your main website when no slug, or incorrect slug, is entered, e.g.
http://wiere.ma/
→http://samwierema.nl/
. - Generates short URLs using only
[a-z0-9]
characters. - Doesn’t create multiple short URLs when you try to shorten the same URL. In this case, the script will simply return the existing short URL for that long URL.
- Can import old bitly links
git clone [email protected]:breyten/go-url-shortener.git
cd go-url-shortener/docker
- Create a config file named
config.(json|yaml|toml)
. Useconfig-example.json
as a example. ./run.sh
docker-compose up -d
- Forward requests from your load balancer to the
gus_web_1
container (port 8080)
- Add tests
- Add checks for duplicate slugs (i.e. make creation of slugs better)