SHELL = /bin/bash -o pipefail export PATH := $(shell go env GOPATH)/bin:$(PATH) ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) SRC_DIR=$(ROOT_DIR)/cmd BIN=$(ROOT_DIR)/wa-profile-api GO_VERSION=$(shell go version | sed -e 's/go version //') build: swagger deps fmt ## Build the app @echo "==> Building for prod with ${GO_VERSION}" @cd $(SRC_DIR) && CGO_ENABLED=0 go build -buildvcs=false -tags=release -o $(BIN) . @echo $(BIN) run: build # Build and run the app @echo "==> Running" @${BIN} fmt: ## Run gofmt @echo "==> Running gofmt" @gofmt -l -s -w `go list -buildvcs=false -f '{{.Dir}}' ${ROOT_DIR}/... | grep -v /vendor/` swagger: swag_install ## Generate API documentation. @swag init -g cmd/main.go deps: ## Install dependencies @echo "==> Installing dependencies" @go mod tidy @go mod vendor swag_install: ifeq (, $(shell command -v swag 2> /dev/null)) @echo "==> Installing swag tool..." @go install github.com/swaggo/swag/cmd/swag@latest endif help: ## Help @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(firstword $(MAKEFILE_LIST)) | \ awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-24s\033[0m %s\n", $$1, $$2}' | \ sed -e 's/\[32m## /[33m/' && printf "\n"