export GOBIN := $(CURDIR)/bin

LINTER_VERSION := v1.27.0
LINTER := $(GOBIN)/golangci-lint-$(LINTER_VERSION)

# These values are included in the build to provide
# extra information in application logs.
NOW := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
COMMIT := $(shell git rev-parse --short HEAD)

LDFLAGS = -s -w \
-X \"main.commit=$(COMMIT)\" \
-X \"main.date=$(NOW)\"

all: build
.PHONY: all

lint: $(LINTER)
	@ $(LINTER) run --timeout=10m
.PHONY: lint

test:
	go test -cover -race ./...
.PHONY: test

check: lint test
.PHONY: check

build: check
	go build -ldflags="$(LDFLAGS)" -o="$(out)" ./cmd/go-statsd-proxy

run: build
	./go-statsd-proxy
.PHONY: run

$(LINTER):
	./scripts/get-linter.sh $(LINTER_VERSION)
