Created
May 18, 2024 11:36
-
-
Save kostaspt/ba7ee77385d4dc457f4cafee373663d8 to your computer and use it in GitHub Desktop.
Makefile for Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIRECTORIES=go list -f '{{.Dir}}' ./... | grep -v /vendor/ | |
PACKAGES=go list ./... | grep -v /vendor/ | |
.PHONY: build | |
build: clean | |
mkdir -p bin/ && go build -o ./bin/ `$(call DIRECTORIES)` | |
.PHONY: clean | |
clean: | |
go clean | |
rm -rf ./bin | |
.PHONY: deps | |
deps: | |
go mod tidy | |
go mod verify | |
.PHONY: format | |
format: | |
gofmt -w `$(call DIRECTORIES)` | |
.PHONY: gitignore | |
gitignore: | |
@wget https://www.toptal.com/developers/gitignore/api/go,goland+all,visualstudiocode,dotenv -q -O .gitignore | |
echo "/bin" >> .gitignore | |
.PHONY: test | |
test: | |
go test -v -mod=vendor `$(call PACKAGES)` | |
.PHONY: test-ci | |
test-ci: | |
go test -v -race -mod=vendor `$(call PACKAGES)` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment