...

Text file src/github.com/gin-gonic/gin/Makefile

Documentation: github.com/gin-gonic/gin

     1GO ?= go
     2GOFMT ?= gofmt "-s"
     3GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
     4PACKAGES ?= $(shell $(GO) list ./...)
     5VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
     6GOFILES := $(shell find . -name "*.go")
     7TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
     8TESTTAGS ?= ""
     9
    10.PHONY: test
    11test:
    12	echo "mode: count" > coverage.out
    13	for d in $(TESTFOLDER); do \
    14		$(GO) test $(TESTTAGS) -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
    15		cat tmp.out; \
    16		if grep -q "^--- FAIL" tmp.out; then \
    17			rm tmp.out; \
    18			exit 1; \
    19		elif grep -q "build failed" tmp.out; then \
    20			rm tmp.out; \
    21			exit 1; \
    22		elif grep -q "setup failed" tmp.out; then \
    23			rm tmp.out; \
    24			exit 1; \
    25		fi; \
    26		if [ -f profile.out ]; then \
    27			cat profile.out | grep -v "mode:" >> coverage.out; \
    28			rm profile.out; \
    29		fi; \
    30	done
    31
    32.PHONY: fmt
    33fmt:
    34	$(GOFMT) -w $(GOFILES)
    35
    36.PHONY: fmt-check
    37fmt-check:
    38	@diff=$$($(GOFMT) -d $(GOFILES)); \
    39	if [ -n "$$diff" ]; then \
    40		echo "Please run 'make fmt' and commit the result:"; \
    41		echo "$${diff}"; \
    42		exit 1; \
    43	fi;
    44
    45vet:
    46	$(GO) vet $(VETPACKAGES)
    47
    48.PHONY: lint
    49lint:
    50	@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
    51		$(GO) get -u golang.org/x/lint/golint; \
    52	fi
    53	for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
    54
    55.PHONY: misspell-check
    56misspell-check:
    57	@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
    58		$(GO) get -u github.com/client9/misspell/cmd/misspell; \
    59	fi
    60	misspell -error $(GOFILES)
    61
    62.PHONY: misspell
    63misspell:
    64	@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
    65		$(GO) get -u github.com/client9/misspell/cmd/misspell; \
    66	fi
    67	misspell -w $(GOFILES)
    68
    69.PHONY: tools
    70tools:
    71	@if [ $(GO_VERSION) -gt 15 ]; then \
    72		$(GO) install golang.org/x/lint/golint@latest; \
    73		$(GO) install github.com/client9/misspell/cmd/misspell@latest; \
    74	elif [ $(GO_VERSION) -lt 16 ]; then \
    75		$(GO) install golang.org/x/lint/golint; \
    76		$(GO) install github.com/client9/misspell/cmd/misspell; \
    77	fi

View as plain text