Install golang-migrate to start creating migration files
brew install golang-migrateCreate the first sql migration file
migrate create -ext sql -dir db/migration -seq init_schemaAdd your sql schemas into up.sql and down.sql files inside db/migration folder
Fire up a postgres container
make postgresCreate a database
make createdbRun the migration files
make migrateupbrew install sqlcsqlc initMake 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 sqlcgo get github.com/lib/pqanother package testing for logs
go get github.com/stretchr/testifyRefer 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/vipercreate 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 ~/.zshrcadd the following then save and exit.
export PATH=$PATH:~/go/bin
source ~/.zshrcWe can mark go interfaces we'd like to mock by
//go:generate mockgen -package=mockdb -destination=../mock/mock_store.go . StoreWe run the go generate on the current project
go generate -v ./...go get github.com/dgrijalva/jwt-goinstall paseto
github.com/o1egl/paseto