https://github.com/covicale/url-shortener-go
Simple URL Shortener made with Go and PostgreSQL
https://github.com/covicale/url-shortener-go
go html mvc postgresql url-shortener
Last synced: 2 months ago
JSON representation
Simple URL Shortener made with Go and PostgreSQL
- Host: GitHub
- URL: https://github.com/covicale/url-shortener-go
- Owner: Covicale
- License: mit
- Created: 2024-06-18T19:20:11.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-04T17:40:47.000Z (almost 2 years ago)
- Last Synced: 2024-07-12T05:03:50.850Z (almost 2 years ago)
- Topics: go, html, mvc, postgresql, url-shortener
- Language: Go
- Homepage:
- Size: 249 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Shortener GO

[](https://img.shields.io/github/last-commit/covicale/url-shortener-go)
[](https://img.shields.io/github/issues-raw/covicale/url-shortener-go)
[](https://img.shields.io/github/issues-pr/covicale/url-shortener-go)
[](https://img.shields.io/github/license/covicale/url-shortener-go)
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.
# Table of Contents
- [URL Shortener GO](#url-shortener-go)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Docker Compose](#docker-compose)
- [Manual Installation](#manual-installation)
- [Usage](#usage)
- [License](#license)
# Installation
First of all, you need to clone the project to your local machine.
```shell
git clone https://github.com/Covicale/url-shortener-go.git
```
After 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.
## Docker Compose
You can use the provided `docker-compose.yml` file to run the project with a single command.
```shell
docker-compose up
```
## Manual Installation
If 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:
```shell
go build -o url-shortener-go cmd/main.go
./url-shortener-go
```
# Usage
In 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.

# License
[MIT license](./LICENSE)