11# TOOLCHAIN
22GO := CGO_ENABLED=0 go
33CGO := CGO_ENABLED=1 go
4- GOFMT := $(GO ) fmt
54
65# ENVIRONMENT
76VERBOSE =
@@ -13,9 +12,6 @@ REVISION := $(shell git rev-parse --short HEAD)
1312RELEASE := $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD) -dev
1413USER := $(shell whoami)
1514
16- # GO TOOLS
17- GOTOOLS := $(shell cat tools.go | grep "_ \"" | awk '{ print $$2 }' | tr -d '"')
18-
1915# MISC
2016COVERPROFILE := coverage.out
2117DIST_DIR := dist
@@ -45,8 +41,6 @@ ifdef VERBOSE
4541endif
4642
4743# FUNCTIONS
48- # func go-run-tool(name)
49- go-run-tool = $(CGO ) run $(shell echo $(GOTOOLS ) | tr ' ' '\n' | grep -w $1)
5044# func go-list-pkg-sources(package)
5145go-list-pkg-sources = $(GO ) list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $(1 )
5246# func go-pkg-sourcefiles(package)
@@ -58,7 +52,7 @@ all: dep fmt lint test build ## Run dep, fmt, lint, test and build
5852.PHONY : build
5953build : dep.stamp $(call go-pkg-sourcefiles, ./...) # # Build the binaries
6054 @echo " >> building binaries"
61- @$(call go-run- tool, goreleaser) build $(GORELEASER_FLAGS )
55+ @$(GO ) tool goreleaser build $(GORELEASER_FLAGS )
6256
6357.PHONY : clean
6458clean : # # Remove build and test artifacts
@@ -78,13 +72,7 @@ dep-clean: ## Remove obsolete dependencies
7872.PHONY : dep-upgrade
7973dep-upgrade : # # Upgrade all direct dependencies to their latest version
8074 @echo " >> upgrading dependencies"
81- @$(GO ) get -d $(shell $(GO ) list -f '{{if not (or .Main .Indirect) }}{{.Path}}{{end}}' -m all)
82- @make dep
83-
84- .PHONY : dep-upgrade-tools
85- dep-upgrade-tools : # # Upgrade all tool dependencies to their latest version
86- @echo " >> upgrading tool dependencies"
87- @$(GO ) get -d $(GOTOOLS )
75+ @$(GO ) get $(shell $(GO ) list -f '{{if not (or .Main .Indirect) }}{{.Path}}{{end}}' -m all)
8876 @make dep
8977
9078.PHONY : dep
@@ -97,22 +85,22 @@ dep.stamp: $(GOMODDEPS)
9785 @touch $@
9886
9987.PHONY : fmt
100- fmt : # # Format and simplify the source code using `gofmt `
88+ fmt : # # Format and simplify the source code using `golangci-lint fmt `
10189 @echo " >> formatting code"
102- @! $( GOFMT ) -s -w $( shell find . -path -prune -o -name ' * .go' -print) | grep ' ^ '
90+ @$( GO ) tool golangci-lint fmt
10391
10492.PHONY : install
10593install : $(GOPATH ) /bin/axiom-syslog-proxy # # Install the binary into the $GOPATH/bin directory
10694
10795.PHONY : lint
10896lint : # # Lint the source code
10997 @echo " >> linting code"
110- @$(call go-run- tool, golangci-lint) run
98+ @$(GO ) tool golangci-lint run
11199
112100.PHONY : test
113101test : # # Run all tests. Run with VERBOSE=1 to get verbose test output ('-v' flag).
114102 @echo " >> running tests"
115- @$(call go-run- tool, gotestsum) $(GOTESTSUM_FLAGS ) -- $(GO_TEST_FLAGS ) ./...
103+ @$(CGO ) tool gotestsum $(GOTESTSUM_FLAGS ) -- $(GO_TEST_FLAGS ) ./...
116104
117105.PHONY : help
118106help :
0 commit comments