Skip to content

Instantly share code, notes, and snippets.

@sohlich
Last active January 6, 2024 07:16
Show Gist options
  • Star 59 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save sohlich/8432e7c1bd56bc395b101d1ba444e982 to your computer and use it in GitHub Desktop.
Save sohlich/8432e7c1bd56bc395b101d1ba444e982 to your computer and use it in GitHub Desktop.
# 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
@JohnVanNote
Copy link

Any value in checking for the GOPATH env variable first, and "doing-something" (failing, fixing) if it is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment