Install golang-migrate to start creating migration files
brew install golang-migrate
Create the first sql migration file
migrate create -ext sql -dir db/migration -seq init_schema
Add your sql schemas into up.sql and down.sql files inside db/migration folder
Fire up a postgres container
make postgres
Create a database
make createdb
Run the migration files
make migrateup
brew install sqlc
sqlc init
Make sure you configure sqlc.yaml file
Create a query file that represents a query to a table in query folder e.g: query/authors.sql
-- name: CreateAuthor :execresult
INSERT INTO authors
(
name, bio
)
VALUES
(
$1, $2
)
RETURNING *;
Now lets generate our sql-go files
make sqlc
go get github.com/lib/pq
another package testing for logs
go get github.com/stretchr/testify
Refer to ci.yml to check how we setup a testing pipeline, with a postgres service, and curling the necessary golang-migration bin.
install viper
go get github.com/spf13/viper
create an app.env file and util/config.go to unmarshal the env variables
use gin server create APIs
install gomock
go install github.com/golang/mock/[email protected]
Make sure mockgen is accessible in cli
vi ~/.zshrc
add the following then save and exit.
export PATH=$PATH:~/go/bin
source ~/.zshrc
We can mark go interfaces we'd like to mock by
//go:generate mockgen -package=mockdb -destination=../mock/mock_store.go . Store
We run the go generate on the current project
go generate -v ./...
go get github.com/dgrijalva/jwt-go
install paseto
github.com/o1egl/paseto