Golang, is a statically typed, compiled programming language designed at Google that aids in building simple, reliable, and efficient software. 99designs/gqlgen is go generate based graphql server library schema first, type safe and enables Codegen.
This boilerplate leverages the Graphql to quickly prototype backend applications. It comes with database, logging, security, and authentication features out of the box.
-
Based on gqlgen.
-
SQLC to Compile SQL to type-safe code for Postgres. But can support MYSQL, SQLite.
-
Paseto for token-based authentication, provide strong token signing algorithms out of the box.
-
godotenv for working with env configurations.
Please make sure to have Docker Desktop operational on the preferred operating system of choice to quickly get started. To get started, please see the following link.
Note: Despite the fact that Docker Desktop comes free for both Mac and Windows, it only supports the Pro edition of Windows 10. A common workaround is to get Docker Toolbox which will bypass the Windows 10 Pro restriction by executing Docker in a VM.
$ brew install golang-migrate
$ brew install sqlc
-
Create postgres container:
make postgres
-
Start postgres container:
make startdb
-
Create database:
make createdb
-
Run db migration up all versions:
make migrateup
-
Run db migration down all versions:
make migratedown
-
Generate schema SQL file with DBML:
make db_schema
-
Generate SQL CRUD with sqlc:
make sqlc
-
Generate DB mock with gomock:
make mock
-
Create a new db migration:
migrate create -ext sql -dir db/migration -seq <migration_name>
-
Run server:
make server
-
Run test:
make test