Skip to content

Commit

Permalink
chore(makefile): add formats check (swaggo#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
easonlin404 authored Mar 15, 2019
1 parent f29f821 commit 4f45ba5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ install:
- if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi

script:
- make fmt-check
- make lint
- make build
- make test
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
GOCMD=$(shell which go)
GOLINT=$(shell which golint)
GOIMPORT=$(shell which goimports)
GOFMT =$(shell which gofmt)
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOLIST=$(GOCMD) list

BINARY_NAME=swag
PACKAGES=$(shell $(GOLIST) ./... | grep -v /example)
GOFILES := $(shell find . -name "*.go" -type f)

all: test build

Expand Down Expand Up @@ -53,6 +56,19 @@ lint:

for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;

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

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

.PHONY: view-covered
view-covered:
$(GOTEST) -coverprofile=cover.out $(TARGET)
Expand Down
6 changes: 3 additions & 3 deletions example/celler/model/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (a Account) Update() error {

var accountMaxID = 3
var accounts = []Account{
Account{ID: 1, Name: "account_1"},
Account{ID: 2, Name: "account_2"},
Account{ID: 3, Name: "account_3"},
{ID: 1, Name: "account_1"},
{ID: 2, Name: "account_2"},
{ID: 3, Name: "account_3"},
}
6 changes: 3 additions & 3 deletions example/celler/model/bottle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func BottleOne(id int) (*Bottle, error) {
}

var bottles = []Bottle{
Bottle{ID: 1, Name: "bottle_1", Account: Account{ID: 1, Name: "accout_1"}},
Bottle{ID: 2, Name: "bottle_2", Account: Account{ID: 2, Name: "accout_2"}},
Bottle{ID: 3, Name: "bottle_3", Account: Account{ID: 3, Name: "accout_3"}},
{ID: 1, Name: "bottle_1", Account: Account{ID: 1, Name: "accout_1"}},
{ID: 2, Name: "bottle_2", Account: Account{ID: 2, Name: "accout_2"}},
{ID: 3, Name: "bottle_3", Account: Account{ID: 3, Name: "accout_3"}},
}
3 changes: 1 addition & 2 deletions testdata/composition/common/response.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package common


type ResponseFormat struct {
Message string `json:"message"`
}
}

0 comments on commit 4f45ba5

Please sign in to comment.