Last active
July 15, 2020 11:35
-
-
Save dev4mobile/14fd7ddf6985e58db92e23fae8b89c92 to your computer and use it in GitHub Desktop.
This is go makefile template
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
GOCMD=go | |
GOBUILD=$(GOCMD) build | |
GOTEST=$(GOCMD) test | |
GOCLEAN=$(GOCMD) clean | |
GOGET=$(GOCMD) get | |
BINARY_NAME=duck | |
all: build test | |
build: | |
$(GOBUILD) -o bin/${BINARY_NAME} -v | |
test: | |
$(GOTEST) -v ./... | |
run: build | |
./bin/${BINARY_NAME} | |
deps: | |
$(GOGET) github.com/gin-gonic/gin | |
#cross compilation | |
compile: | |
#Linux | |
GOOS=linux GOARCH=amd64 $(GOBUILD) -o bin/$(BINARY)-linux-amd64 -v | |
#MacOS | |
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o bin/$(BINARY)-darwin-amd64 -v | |
#Windows | |
GOOS=windows GOARCH=amd64 $(GOBUILD) -o bin/$(BINARY)-windows-amd64 -v | |
#docker build | |
docker-build: | |
docker run -it -v "${PWD}":/usr/src/myapp -w /usr/src/myapp -e GOOS=linux -e GOARCH=amd64 -e GOPROXY=https://goproxy.io,direct golang:latest ${GOBUILD} -o "$(BINARY_NAME)" -v | |
clean: | |
$(GOCLEAN) | |
-rm -rf bin/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment