Go server boilerplate with PostgreSQL
NOTE:
We use Makefile to run all our scripts so install it first if you don't have it
- On Windows
winget install GnuWin32.Make
- On Mac
brew install make
- On Linux
use your distro's package manager to install
-
Clone the repository
-
Go inside the directory
cd <dir-name>
- Initialize go module
go mod init <your-project-name>
- Organize imports
make init
- Start the server in Devlopment mode
make watch
- Start the server
make run
- Build the application
make build
- Install tern
go install github.com/jackc/tern/v2@latest
- Make new migration
tern new -m internal/database/sql/migrations/ name_of_migration
- Run the migration
make migrate
- Write sql queries insite
internal/database/sql/migrations/
direcotry.
to reference how to properly write the query go here
- Generate fully type-safe idiomatic Go code from SQL.
make generate