Last active
October 20, 2018 03:55
-
-
Save alamin-mahamud/2be1ec72c9a67089f8ec5126696ceb12 to your computer and use it in GitHub Desktop.
Makefile for Golang
This file contains hidden or 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
| # Go parameters | |
| GOCMD=go | |
| GOBUILD=$(GOCMD) build | |
| GOCLEAN=$(GOCMD) clean | |
| GOTEST=$(GOCMD) test | |
| GOGET=$(GOCMD) get | |
| BINARY_NAME=mybinary | |
| BINARY_UNIX=$(BINARY_NAME)_unix | |
| all: test build | |
| build: | |
| $(GOBUILD) -o $(BINARY_NAME) -v | |
| test: | |
| $(GOTEST) -v ./... | |
| clean: | |
| $(GOCLEAN) | |
| rm -f $(BINARY_NAME) | |
| rm -f $(BINARY_UNIX) | |
| run: | |
| $(GOBUILD) -o $(BINARY_NAME) -v ./... | |
| ./$(BINARY_NAME) | |
| deps: | |
| $(GOGET) github.com/markbates/goth | |
| $(GOGET) github.com/markbates/pop | |
| # Cross compilation | |
| build-linux: | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v | |
| docker-build: | |
| docker run --rm -it -v "$(GOPATH)":/go -w /go/src/bitbucket.org/rsohlich/makepost golang:latest go build -o "$(BINARY_UNIX)" -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment