SmlLnk is a URL shortener. I wrote this for fun because I missed Go
- Clone the project
git clone https://github.com/jackjohn7/smllnk.git
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
- 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.
- 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.
- Run migrations
goose up
- Run the project
air # or go run cmd/server/main.go
- Configure environment variables
cp .env.example .env
Open .env
in your editor and configure to your liking.
- Compose
docker compose up