Last active
July 4, 2019 06:50
-
-
Save ruiqiliu/5659b239d9c53bbf3ceb2b35c2b36753 to your computer and use it in GitHub Desktop.
go project Makefile demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GOPROXY=http://10.75.203.36:9090 | |
export GOBIN=$(CURDIR)/bin | |
FLAGS := -gcflags=all="-N -l" | |
GO := go | |
GOVET := go vet -all | |
GOLINT := golint | |
GOLEX := golex | |
GOBUILD := go build | |
GOCLEAN := go clean | |
GOINSTALL := go install | |
GOTEST := go test -cover -vet=off -parallel=1 | |
GOVET := go vet -all | |
COMMANDS := redisadapter logswitch | |
PACKAGES := $(shell go list ./... | grep -vE 'cmd' | grep -vE 'test') | |
.PHONY: all debug vet test gocyclo lint release build clean package $(COMMANDS) | |
all: debug | |
debug: build | |
# -tags 用于条件编译 | |
# //+build !debug | |
release: FLAGS = -tags "release" | |
release: clean $(COMMANDS) | |
race: FLAGS = -race | |
race: clean $(COMMANDS) | |
build: $(COMMANDS) | |
cover: clean | |
@go version | |
redisadapter: | |
$(GOINSTALL) $(FLAGS) ./cmd/redisadapter | |
logswitch: | |
$(GOINSTALL) $(FLAGS) github.com/projec-name/log/cmd/logswitch | |
clean: | |
cd $(GOBIN); rm -f $(COMMANDS) | |
gocyclo: | |
gocyclo -over 10 ./ | |
test: | |
@$(GOTEST) $(PACKAGES) | |
vet: | |
$(GOVET) $(PACKAGES) | |
lint: | |
$(GOLINT) $(PACKAGES) | |
package: | |
@cd $(CURDIR)/build; ./package.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment