go version - 1.2.1
go mod tidy
orgo mod vendor
go install github.com/cosmtrek/air@latest
go install github.com/swaggo/swag/cmd/swag@latest
env : APP_HOME
, DEBUG
, TEST
, env
, port
env=dev air
- Run the server with hot reloadswag init
- Generate swagger docsdocker build -t go-boilerplate .
- Build docker imagedocker run -e "env=dev" -p 8080:8080 go-boilerplate
- Run docker image
- Fiber - https://github.com/gofiber/fiber
- Validator - https://github.com/go-playground/validator
- DI - https://github.com/uber-go/fx
- Logger - https://github.com/uber-go/zap
- Errors - https://github.com/cockroachdb/errors
url := config.Apis + consts.GetProductDetailUrl + strconv.Itoa(paymentID)
requestInfo := resty.RequestInfo{
Uri: url,
Method: resty.MethodGET,
Headers: map[string]string{"Content-Type": "application/json"},
Query: map[string]string{},
Body: nil,
Timeout: 0,
RetryCount: 0,
RetryBackOff: 0,
IsSkipSSL: false,
}
res, err := svc.resty.Request(requestInfo)
if err != nil {
return errors.Wrap(err, "failed to get product detail")
}
err = json.Unmarshal(res.Body, &productDetail)
if err != nil {
return errors.Wrap(err, "failed to unmarshal message")
}