Skip to content

Commit

Permalink
Merge pull request #47 from cbroglie/golangci-lint
Browse files Browse the repository at this point in the history
Migrate to golangci-lint
  • Loading branch information
cbroglie authored Jul 13, 2020
2 parents e9ee1d7 + 8658597 commit 2ebfd28
Show file tree
Hide file tree
Showing 1,741 changed files with 460,105 additions and 441 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
env:
- GO111MODULE=on
- CGO_ENABLED=1
- CGO_ENABLED=0
- GOFLAGS=-mod=vendor
- GOPROXY=off
builds:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: go

go:
- 1.13.x
- 1.14.x
- master

script: make ci
Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ fmt:
go fmt ./...

.PHONY: lint
lint: bin/golint
go list ./... | xargs -L1 ./bin/golint -set_exit_status
lint: bin/golangci-lint
./bin/golangci-lint run ./...

bin/golint: $(shell find . -type f -name '*.go')
@mkdir -p $(dir $@)
go build -o $@ ./vendor/golang.org/x/lint/golint
SOURCES := $(shell find . -name '*.go')
BUILD_FLAGS ?= -v
LDFLAGS ?= -w -s

bin/%: $(shell find . -type f -name '*.go')
@mkdir -p $(dir $@)
go build -o $@ ./cmd/$(@F)
bin/golangci-lint: $(SOURCES)
go build -o bin/golangci-lint ./vendor/github.com/golangci/golangci-lint/cmd/golangci-lint

bin/%: $(SOURCES)
CGO_ENABLED=0 go build -o $@ $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" ./cmd/$(@F)
3 changes: 1 addition & 2 deletions cmd/mustache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ func main() {

func run(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
cmd.Usage()
return nil
return cmd.Usage()
}

var data interface{}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/cbroglie/mustache

go 1.13
go 1.14

require (
github.com/spf13/cobra v0.0.5
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
gopkg.in/yaml.v2 v2.2.7
github.com/golangci/golangci-lint v1.28.3
github.com/spf13/cobra v1.0.0
gopkg.in/yaml.v2 v2.3.0
)
560 changes: 545 additions & 15 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion mustache.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ func renderSection(section *sectionElement, contextChain []interface{}, buf io.W
func renderElement(element interface{}, contextChain []interface{}, buf io.Writer) error {
switch elem := element.(type) {
case *textElement:
buf.Write(elem.text)
_, err := buf.Write(elem.text)
return err
case *varElement:
defer func() {
if r := recover(); r != nil {
Expand Down
2 changes: 1 addition & 1 deletion mustache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestMissing(t *testing.T) {
output, err := Render(test.tmpl, test.context)
if err == nil {
t.Errorf("%q expected missing variable error but got %q", test.tmpl, output)
} else if strings.Index(err.Error(), "Missing variable") == -1 {
} else if !strings.Contains(err.Error(), "Missing variable") {
t.Errorf("%q expected missing variable error but got %q", test.tmpl, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
package tools

import (
_ "golang.org/x/lint/golint"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
)
5 changes: 5 additions & 0 deletions vendor/github.com/BurntSushi/toml/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/BurntSushi/toml/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/BurntSushi/toml/COMPATIBLE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/BurntSushi/toml/COPYING

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/BurntSushi/toml/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

218 changes: 218 additions & 0 deletions vendor/github.com/BurntSushi/toml/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ebfd28

Please sign in to comment.