This project aim to serve multiple saas(software as a service) in the backend side.
Inspired by: https://dasarpemrogramangolang.novalagung.com/C-project-layout-structure.html
Thanks to: https://github.com/golang-migrate/migrate
Download to inside the project: curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.darwin-amd64.tar.gz | tar xvz
Create new migrations file: ./migrate create -ext sql -dir migration {file_name}
Migrations up: ./migrate -path {FILE_PATH} -database "{DATABASE_URL" up
Migrations down: ./migrate -path {FILE_PATH} -database "{DATABASE_URL" down
go test -v ./test/functional/...
go test -v ./cmd/user/userhandler
With coverage:
unit:
go test -coverprofile=coverage.out ./cmd/user/userhandler
go tool cover -html=coverage.out -o coverage.html
Thanks to: https://github.com/k1LoW/tbls
Thanks to: https://github.com/vektra/mockery
mockery --name={InterfaceName} --output={path}. Example: mockery --name=UserUsecase --output=/cmd/user/mocks
- Install
aws
cli - Install
docker
&docker-compose
- Run: make docker-compose-localstack
- If you find
Waiting for all LocalStack services to be ready
log often, be patient :). It will happen for a while.
- export AWS_SECRET_ACCESS_KEY=${ACCESS_KEY_SECRET} AWS_ACCESS_KEY_ID=${ACCESS_KEY_ID}
- aws --endpoint-url=http://localhost:4566 s3 mb s3://{bucket_name}. Example:
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket
- aws --endpoint-url=http://localhost:4566 s3api put-object --bucket {bucket_name} --key {folder}. Example:
aws --endpoint-url=http://localhost:4566 s3api put-object --bucket my-bucket --key image/user/
We use sqlc
to generate go code from sql. You need to install sqlc
first.
- Install sqlc in the project root, see the
sqlc
documentation: https://docs.sqlc.dev/en/latest/index.html - Generate new go code from the query
./sqlc generate --file=database/sqlc.yaml