https://github.com/settermjd/small-go-url-shortener
https://github.com/settermjd/small-go-url-shortener
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/settermjd/small-go-url-shortener
- Owner: settermjd
- Created: 2024-02-12T03:04:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-06T11:07:05.000Z (over 2 years ago)
- Last Synced: 2025-03-13T03:16:17.028Z (over 1 year ago)
- Language: CSS
- Size: 9.02 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Go URL Shortener
This is a small, simplistic URL shortener written in Go.
It doesn't have near the functionality of sites such as bit.ly.
However, it does a good job of showing the essence of how a URL shortener works.
## Prerequisites
To use the application, you'll need the following:
- A recent version of [Go](https://go.dev/dl/).
1.22.0 is the current version at the time of writing.
- [The Command Line Shell for SQLite](https://www.sqlite.org/cli.html).
This is required for provisioning the SQLite database during setup.
To develop the application, you'll need the following, additional, dependencies:
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
This is required to install and run the frontend tooling.
## Getting started
To set up the application, clone it locally, change into the cloned project directory, and install the required Go modules, by running the following commands.
```bash
git clone git@github.com:settermjd/small-go-url-shortener.git
cd small-go-url-shortener
go mod tidy
```
## Setting up the database
To set up the database, run the following command in your terminal.
```bash
sqlite3 data/database.sqlite3 < docs/database/load.sql
```
This will provision the database, creating the (sole) table, `urls`.
It won't load any default data into the table, however.
So, you should insert some records by running the following commands, after replacing the placeholders with data of your choice.
```sql
INSERT INTO urls (original_url, shortened_url, clicks) VALUES
("<>", "https://shoRtkl9187ds", 347),
("<>", "https://sh0Rtkl9187es", 2809);
```