Skip to content

Commit

Permalink
add Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Jul 7, 2017
1 parent 7e6f49c commit b37ce3e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,3 +24,4 @@ _testmain.go
*.prof
vendor/*
!vendor/vendor.json
coverage.out
9 changes: 8 additions & 1 deletion .travis.yml
Expand Up @@ -7,8 +7,15 @@ go:
- 1.8.x
- tip

install:
- make install

script:
- go test -v -covermode=atomic -coverprofile=coverage.out
- make vet
- make fmt-check
- make embedmd
- make misspell-check
- make test

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
61 changes: 61 additions & 0 deletions Makefile
@@ -0,0 +1,61 @@
GOFMT ?= gofmt "-s"
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")

all: build

install: deps
govendor sync

.PHONY: test
test:
go test -v -covermode=count -coverprofile=coverage.out

.PHONY: fmt
fmt:
$(GOFMT) -w $(GOFILES)

.PHONY: fmt-check
fmt-check:
# get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;

vet:
go vet $(PACKAGES)

deps:
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/kardianos/govendor; \
fi
@hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/campoy/embedmd; \
fi

embedmd:
embedmd -d *.md

.PHONY: lint
lint:
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/golang/lint/golint; \
fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;

.PHONY: misspell-check
misspell-check:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -error $(GOFILES)

.PHONY: misspell
misspell:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -w $(GOFILES)
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -27,6 +27,7 @@ import "github.com/gin-contrib/multitemplate"

See [example/example.go](example/example.go)

[embedmd]:# (example/example.go go)
```go
package main

Expand All @@ -39,7 +40,6 @@ func createMyRender() multitemplate.Render {
r := multitemplate.New()
r.AddFromFiles("index", "templates/base.html", "templates/index.html")
r.AddFromFiles("article", "templates/base.html", "templates/index.html", "templates/article.html")

return r
}

Expand Down

0 comments on commit b37ce3e

Please sign in to comment.