Just a bloilerplate for a GoLang service with Fiber and SQLC.
- Postgres Database Integration With PGX
- Raw automated-generation queries with SQLC
- JWT generation and validation middleware with HS512 alg
- Ready user resource with login, fetch user data, update and soft delete
- Error logger integrated with Fiber and easy to format
- Direct SSL support for production mode
Please help me to support this boilerplate if you can.
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
set CGO_ENABLED=0 & set GOOS=windows& go build -o ./build/server.exe
set CGO_ENABLED=0 & set GOOS=linux& go build -o ./build/server
set CGO_ENABLED=0 & set GOOS=darwin& go build -o ./build/server
CGO_ENABLED=0 GOOS=windows go build -o ./build/server.exe
CGO_ENABLED=0 GOOS=linux go build -o ./build/server
CGO_ENABLED=0 GOOS=darwin go build -o ./build/server
For MacOS, it will be probably the same that Linux.
migrate create -ext sql -dir sql/migration -seq file_name
grant all on database your_database to your_user;
grant usage on schema public TO your_user;
Up:
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/your_database?sslmode=disable"
make migrate-up
Down:
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/your_database?sslmode=disable"
make migrate-down
sudo cp ./boilerplate-go-fiber-sqlc.service /etc/systemd/system/
sudo systemctl enable boilerplate-go-fiber-sqlc.service
sudo systemctl restart boilerplate-go-fiber-sqlc.service
APP_ENV=dev
APP_HEADER=Your Project Server Header
APP_NAME=Your Project Name
APP_HOST=0.0.0.0
APP_PORT=8080
DATABASE_URL=postgresql://{user}:{password}@{host}:{port}/{dbname}?sslmode=disable
JWT_ISSUER=your_project
JWT_SECRET=your_secret
Note: you need to enable sslmode if you are in production mode!