URL Shortener GO is a simple URL shortener project written in Go. It uses a PostgreSQL database to store the shortened URLs and native net/http package to handle the requests.
This project uses JWT for authentication and authorization. The frontend is plain HTML, CSS, and JavaScript with no frameworks or libraries, to keep it simple and focus on the backend.
First of all, you need to clone the project to your local machine.
git clone https://github.com/Covicale/url-shortener-go.gitAfter the cloning is complete, you need set the environment variables.
In the project, you will find a .env.demo file. You need to rename this file to .env and update the values according to your environment.
There are two ways to install this project: With docker-compose or manual installation.
You can use the provided docker-compose.yml file to run the project with a single command.
docker-compose upIf you don't want to use Docker, you can install the project manually. Pre-requisites are Go and PostgreSQL:
- Go: 1.22 or higher
- PostgreSQL: 16 or higher
After launching the PostgreSQL server, you need to create a database and a user for the project.
There is a internal/db/schema/schema.sql file. You can use this file to create the database.
Once the database is created, you can simply run the project with:
go build -o url-shortener-go cmd/main.go
./url-shortener-goIn your browser, navigate to http://localhost:${PORT} to see the URL Shortener GO in action.
First, you need to register a new user. After registering, you can log in with your credentials.
After logging in, you can shorten URLs and see the list of shortened URLs.

