SHARE
TWEET

Untitled

a guest Jun 20th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. VERSION := 1.0.0
  2. SHELL := /bin/bash
  3. GO := GO15VENDOREXPERIMENT=1 go
  4. NAME := go-demo-6
  5. OS := $(shell uname)
  6. MAIN_GO := main.go
  7. ROOT_PACKAGE := $(GIT_PROVIDER)/vfarcic/$(NAME)
  8. GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
  9. PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/)
  10. PKGS := $(shell go list ./... | grep -v /vendor | grep -v generated)
  11. BUILDFLAGS := ''
  12. CGO_ENABLED = 0
  13. VENDOR_DIR=vendor
  14.  
  15. all: build
  16.  
  17. check: fmt build test
  18.  
  19. build:
  20.     CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
  21.  
  22. test:
  23.     CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v
  24.  
  25. full: $(PKGS)
  26.  
  27. install:
  28.     GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO)
  29.  
  30. fmt:
  31.     @FORMATTED=`$(GO) fmt $(PACKAGE_DIRS)`
  32.     @([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
  33.  
  34. clean:
  35.     rm -rf build release
  36.  
  37. linux:
  38.     CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
  39.  
  40. .PHONY: release clean
  41.  
  42. FGT := $(GOPATH)/bin/fgt
  43. $(FGT):
  44.     go get github.com/GeertJohan/fgt
  45.  
  46. GOLINT := $(GOPATH)/bin/golint
  47. $(GOLINT):
  48.     go get github.com/golang/lint/golint
  49.  
  50. $(PKGS): $(GOLINT) $(FGT)
  51.     @echo "LINTING"
  52.     @$(FGT) $(GOLINT) $(GOPATH)/src/$@/*.go
  53.     @echo "VETTING"
  54.     @go vet -v $@
  55.     @echo "TESTING"
  56.     @go test -v $@
  57.  
  58. .PHONY: lint
  59. lint: vendor | $(PKGS) $(GOLINT) # ❷
  60.     @cd $(BASE) && ret=0 && for pkg in $(PKGS); do \
  61.         test -z "$$($(GOLINT) $$pkg | tee /dev/stderr)" || ret=1 ; \
  62.     done ; exit $$ret
  63.  
  64. unittest:
  65.     CGO_ENABLED=$(CGO_ENABLED) $(GO) test --run UnitTest \
  66.     -v -coverprofile=coverage.txt -covermode=atomic
  67.  
  68.  
  69. functest:
  70.     CGO_ENABLED=$(CGO_ENABLED) $(GO) \
  71.     test -test.v --run FunctionalTest \
  72.     -coverprofile=coverage.txt -covermode=atomic
  73.  
  74.  
  75. integtest:
  76.     DURATION=1 \
  77.     CGO_ENABLED=$(CGO_ENABLED) $(GO) \
  78.     test -test.v --run ProductionTest \
  79.     -coverprofile=coverage.txt -covermode=atomic
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top