.PHONY: all all: build FORCE: ; SHELL := env LIBRARY_ENV=$(LIBRARY_ENV) $(SHELL) LIBRARY_ENV ?= dev BIN_DIR = $(PWD)/bin .PHONY: build clean: rm -rf bin/* dependencies: go mod download build: dependencies build-api build-cmd build-api: go build -tags $(LIBRARY_ENV) -o ./bin/api api/main.go build-cmd: go build -tags $(LIBRARY_ENV) -o ./bin/search cmd/main.go linux-binaries: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -tags "$(LIBRARY_ENV) netgo" -installsuffix netgo -o $(BIN_DIR)/api api/main.go CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -tags "$(LIBRARY_ENV) netgo" -installsuffix netgo -o $(BIN_DIR)/search cmd/main.go ci: dependencies test build-mocks: @go get github.com/golang/mock/gomock @go install github.com/golang/mock/mockgen @~/go/bin/mockgen -source=usecase/book/interface.go -destination=usecase/book/mock/book.go -package=mock @~/go/bin/mockgen -source=usecase/user/interface.go -destination=usecase/user/mock/user.go -package=mock @~/go/bin/mockgen -source=usecase/loan/interface.go -destination=usecase/loan/mock/loan.go -package=mock test: go test -tags testing ./... fmt: ## gofmt and goimports all go files find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done