Skip to content

Commit

Permalink
Merge pull request #30 from hikhvar/allow-alternative-go-binary
Browse files Browse the repository at this point in the history
Don't hardcode go binary path in makefile
  • Loading branch information
hikhvar authored Jan 23, 2021
2 parents 90584b7 + d02411d commit af8098f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
ifndef GOBINARY
GOBINARY:="go"
endif

ifndef GOPATH
GOPATH:=$(shell go env GOPATH)
GOPATH:=$(shell $(GOBINARY) env GOPATH)
endif

ifndef GOBIN
GOBIN:=$(GOPATH)/bin
endif

ifndef GOARCH
GOARCH:=$(shell go env GOARCH)
GOARCH:=$(shell $(GOBINARY) env GOARCH)
endif

ifndef GOOS
GOOS:=$(shell go env GOOS)
GOOS:=$(shell $(GOBINARY) env GOOS)
endif

ifndef GOARM
GOARM:=$(shell go env GOARM)
GOARM:=$(shell $(GOBINARY) env GOARM)
endif

ifndef TARGET_FILE
Expand All @@ -31,14 +35,14 @@ lint:
golangci-lint run

test:
go test ./...
go vet ./...
$(GOBINARY) test ./...
$(GOBINARY) vet ./...

build:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(TARGET_FILE) ./cmd
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBINARY) build -o $(TARGET_FILE) ./cmd

static_build:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(TARGET_FILE) -a -tags netgo -ldflags '-w -extldflags "-static"' ./cmd
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBINARY) build -o $(TARGET_FILE) -a -tags netgo -ldflags '-w -extldflags "-static"' ./cmd

container:
docker build -t mqtt2prometheus:latest .
Expand Down

0 comments on commit af8098f

Please sign in to comment.