Architecture hexagonal
go v1.19
Libs:
- Sqlc - Db https://github.com/kyleconroy/sqlc
- Gin - Http https://github.com/gin-gonic/gin
- Gqlgen - Graphql https://github.com/99designs/gqlgen
- Logger ZAP - https://github.com/uber-go/zap
- Config Viper - https://github.com/spf13/viper
- Bcrypt
- JWT - https://github.com/golang-jwt/jwt
- Paseto - https://github.com/o1egl/paseto
- Uuid - https://github.com/google/uuid
- Clone this repository
- Install go v1.19+
Execute in terminal:
go mod tidy
make server
./docs/api
http://localhost:8080/graph/v1
- docker network create template-network
- docker run --name postgres12 --network template-network -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=ORiBLEcTUrdS -d postgres:12-alpine
- docker build -t templatego:latest .
- docker run --name template_go --network template-network -p 8080:8080 -e DB_SOURCE="postgresql://root:ORiBLEcTUrdS@postgres12:5432/template_go?sslmode=disable" -e GIN_MODE=release templatego:latest
Run the make command to generate the migration file in
the db/migrations folder, after adding table creation
commands to the 'UP' and 'DOWN' file, add a command to remove.
sudo curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
sudo echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list
sudo apt-get update
sudo apt-get install -y migrate
make create-migration arg=<name>
Create file
make create-migration arg=<name>
Submit migrations - Migrations execute on play API
make migrateup
Revert migrations
make migratedown
Submit one migration - Migrations execute on play API
make migrateup1
Revert one migration
make migratedown1
Generate random 32 bytes
openssl rand -hex 64 | head -c 32