URL Shortener in Go
Go HTML
Project Overview
-
A fully functional, minimal URL shortener implemented in Go.
-
A speedrun project for learning that I made while reading a system design article about Bitly
-
This project consists of three relatively simple handlers:
- HandleForm: Displays a form to input URLs for shortening.
- Shorten: Processes the submitted URL and generates a short key.
- Redirect: Redirects to the original URL when a shortened URL is accessed.
Features
Shortens long URLs (or any URL) into compact links that redirect to the original
What I Learned
- Translating system design concepts into working code
- Using Go’s “html/template” package to parse user input from a form
- Working with Go’s “net/http” package to handle URL redirects
- Error handling, the idiomatic Go way
- Accounting for edge cases while writing the handlers
Possible Improvements
- Use base62-encoding with unique IDs to ensure uniqueness
- Data persistence for shortened URLs