refactor(Makefile): allow overriding default go program (#1593)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Bo-Yi Wu · committed by 田欧 · parent 268e307 · Browse files · 2 files·+18 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+18 added−23 removed
- other:+18 added−23 removed
Provenance
- Commit
01ca253- Tree
24840cf- Author
Bo-Yi Wu <appleboy.tw@gmail.com>- Committer
田欧 <thinkerou@gmail.com>- Parent
268e307
2 files changed+18 added−23 removed
deleted:coverage.sh-13 removed
12345678910111213#!/usr/bin/env bash
set -e
echo "mode: count" > coverage.out
for d in $(go list ./... | grep -E 'gin$|binding$|render$' | grep -v 'examples'); do go test -v -covermode=count -coverprofile=profile.out $d if [ -f profile.out ]; then cat profile.out | grep -v "mode:" >> coverage.out rm profile.out fidonemodified:Makefile+18 added-10 removed
1+GO ?= go2 GOFMT ?= gofmt "-s"2-PACKAGES ?= $(shell go list ./... | grep -v /vendor/)3-VETPACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /examples/)3+PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)4+VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)5 GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")6+TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)7 8 all: install9 10 install: deps11 govendor sync12 13 .PHONY: test14 test:13- sh coverage.sh15+ echo "mode: count" > coverage.out16+ for d in $(TESTFOLDER); do \17+ $(GO) test -v -covermode=count -coverprofile=profile.out $$d; \18+ if [ -f profile.out ]; then \19+ cat profile.out | grep -v "mode:" >> coverage.out; \20+ rm profile.out; \21+ fi; \22+ done23 24 .PHONY: fmt25 fmt:26 $(GOFMT) -w $(GOFILES)27 28 .PHONY: fmt-check29 fmt-check:21- # get all go files and run go fmt on them30 @diff=$$($(GOFMT) -d $(GOFILES)); \31 if [ -n "$$diff" ]; then \32 echo "Please run 'make fmt' and commit the result:"; \33 echo "$${diff}"; \34 exit 1; \35 fi;36 37 vet:30- go vet $(VETPACKAGES)38+ $(GO) vet $(VETPACKAGES)39 40 deps:41 @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \34- go get -u github.com/kardianos/govendor; \42+ $(GO) get -u github.com/kardianos/govendor; \43 fi44 @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \37- go get -u github.com/campoy/embedmd; \45+ $(GO) get -u github.com/campoy/embedmd; \46 fi47 48 embedmd:49 embedmd -d *.md50 51 .PHONY: lint52 lint:53 @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \46- go get -u golang.org/x/lint/golint; \54+ $(GO) get -u golang.org/x/lint/golint; \55 fi56 for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;57 58 .PHONY: misspell-check59 misspell-check:60 @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \53- go get -u github.com/client9/misspell/cmd/misspell; \61+ $(GO) get -u github.com/client9/misspell/cmd/misspell; \62 fi63 misspell -error $(GOFILES)64 65 .PHONY: misspell66 misspell:67 @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \60- go get -u github.com/client9/misspell/cmd/misspell; \68+ $(GO) get -u github.com/client9/misspell/cmd/misspell; \69 fi70 misspell -w $(GOFILES)