Skip to content

jackjohn7/smllnk

Repository files navigation

SmlLnk (Small Link)

SmlLnk is a URL shortener. I wrote this for fun because I missed Go

Getting Started (Host)

  1. Clone the project
git clone https://github.com/jackjohn7/smllnk.git
  1. Install deps (air, goose, templ)

You can install TailwindCSS either using the standalone CLI tool or by using npm. Just ensure it's in your path.

go install github.com/cosmtrek/air@latest # install air
go install github.com/a-h/templ/cmd/templ@latest # install templ
go install github.com/pressly/goose/v3/cmd/goose@latest # install goose
  1. Set up DB and Environment

If you want to use .env, perform the following command:

cp .env.example .env

Ensure that these variables are correct for your environment.

You need to set the following environment variables:

GOOSE_DRIVER=postgres
GOOSE_DBSTRING=$DATABASE_URL
GOOSE_MIGRATION_DIR=./db/migrations/

The DATABASE_URL is the connection string to the postgres database. I highly recommend using direnv if you simply want to define these in your .env file. You can very simply add the following to your .envrc to achieve these results.

dotenv

Direnv will now read your .env file for variables.

  1. Create database (docker)
./start-database.sh

Or start it however you want. Just ensure you've got the correct connection string in your environment variables.

  1. Run migrations
goose up
  1. Run the project
air # or go run cmd/server/main.go

Getting Started (Docker Compose) (Unsupported for now)

  1. Configure environment variables
cp .env.example .env

Open .env in your editor and configure to your liking.

  1. Compose
docker compose up

About

URL shortener written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published