A SaaS that shortens url to make it cleaner to share.
Install migrate for PostgreSQL migrations:
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latestInstall SQLc for generating Go code from SQL queries:
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latestRun postgres in a docker container:
docker run --name postgres-urls \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=pass \
-e POSTGRES_DB=url_db \
-p 5432:5432 \
-d postgresRun redis in a docker container:
docker run --name redis-url \
-p 6379:6379 \
-d redismigrate -path database/migrate \
-database "postgres://user:pass@localhost:5432/url_db?sslmode=disable" \
upmigrate -path database/migrate \
-database "postgres://user:pass@localhost:5432/url_db?sslmode=disable" \
drop -fMake sure to set the timezone in PostgreSQL to UTC. You can do this by running the following command in the PostgreSQL shell:
ALTER DATABASE url_db SET timezone TO 'UTC';cp config.example.toml config.tomlAnd edit the config.toml file with your database and redis credentials.
go run main.go