Merge pull request #30 from hikhvar/allow-alternative-go-binary

Don't hardcode go binary path in makefile
This commit is contained in:
Christoph Petrausch
2021-01-23 22:15:26 +01:00
committed by GitHub
+12 -8
View File
@@ -1,5 +1,9 @@
ifndef GOBINARY
GOBINARY:="go"
endif
ifndef GOPATH
GOPATH:=$(shell go env GOPATH)
GOPATH:=$(shell $(GOBINARY) env GOPATH)
endif
ifndef GOBIN
@@ -7,15 +11,15 @@ ifndef GOBIN
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
@@ -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 .