A project boilerplate to make a go application with Fiber
This boilerplate is intended to be used as a starting point for a go application. It is not intended to be used as a but it is can be.
brew install sonar-scanner
git clone https://github.com/kondohiroki/go-boilerplate.git
go mod download
cp config/config.example.yaml config/config.yaml
docker compose up -d
go run main.go migrate
# Run normally
go run main.go serve-api
# Run with hot reload
air serve-api
# Run unit-test
make unit-test
# Run api-test
make api-test
# Create sonar scret
touch .sonar.secret
echo "your-sonar-token" > .sonar.secret
# Add secret to .sonar.secret
# Get from sonar web
For those const
, use capitalized SNAKE_CASE for public constant. For private, constant name should led by _ (underscore).
Good Example
// public
const BAD_REQUEST int = 400
// private
const _UNAUTHORIZED int = 401
Bad Example
const BadRequest int = 400
const unauthorized int = 401
config/config.yaml
(ignored by git)
cmd/root.go
config/config.yaml
is loaded by default--config
flaginternal/app/<your-handler>/<xxx>.go
internal/logger/zap_logger.go
NewZapLogger
functionjob/
scheduler/scheduler.go
config/config.yaml