Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Go modules support but keep dep support #255

Merged
merged 11 commits into from
Mar 20, 2019
16 changes: 5 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.10.3
environment:
GOBIN: /tmp/workspace/bin

working_directory: /go/src/github.com/tendermint/go-amino
- image: circleci/golang:1.12.0

steps:
- run: mkdir -p /tmp/workspace/bin
- run: mkdir -p /tmp/workspace/profiles
- checkout
- restore_cache:
keys:
- v1-dep-{{ .Branch }}
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: test
command: |
export PATH="$GOBIN:$PATH"
go env
go version
make get_tools && make get_vendor_deps && make test
make get_tools && make && make test
- save_cache:
key: v1-dep-{{ .Branch }}
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- /go/pkg
- "/go/pkg/mod"
65 changes: 65 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
run:
deadline: 1m

linters:
enable-all: true
disable:
- gocyclo
- golint
- gosimple
- goimports
- unused
- govet
- deadcode
- structcheck
- maligned
- errcheck
- staticcheck
- dupl
- ineffassign
- interfacer
- unconvert
- goconst
- unparam
- nakedret
- lll
- gochecknoglobals
- gocritic
- gochecknoinits
- scopelint
- stylecheck

# linters-settings:
# govet:
# check-shadowing: true
# golint:
# min-confidence: 0
# gocyclo:
# min-complexity: 10
# maligned:
# suggest-new: true
# dupl:
# threshold: 100
# goconst:
# min-len: 2
# min-occurrences: 2
# depguard:
# list-type: blacklist
# packages:
# # logging is allowed only by logutils.Log, logrus
# # is allowed to use only in logutils package
# - github.com/sirupsen/logrus
# misspell:
# locale: US
# lll:
# line-length: 140
# goimports:
# local-prefixes: github.com/golangci/golangci-lint
# gocritic:
# enabled-tags:
# - performance
# - style
# - experimental
# disabled-checks:
# - wrapperFunc
# - commentFormatting # https://github.com/go-critic/go-critic/issues/755
41 changes: 30 additions & 11 deletions Gopkg.lock

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

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

[[constraint]]
name = "github.com/davecgh/go-spew"
version = "1.1.0"
version = "1.1.1"

[[constraint]]
branch = "master"
name = "github.com/google/gofuzz"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"
version = "1.3.0"

[prune]
go-tests = true
Expand Down
61 changes: 10 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
GOTOOLS = \
github.com/golang/dep/cmd/dep \
gopkg.in/alecthomas/gometalinter.v2
GOTOOLS_CHECK = dep gometalinter.v2
github.com/golangci/golangci-lint/cmd/golangci-lint
GOTOOLS_CHECK = golangci-lint

all: check_tools get_vendor_deps test metalinter
all: check_tools test

########################################
### Build
Expand All @@ -25,17 +24,11 @@ check_tools:

get_tools:
@echo "--> Installing tools"
go get -u -v $(GOTOOLS)
@gometalinter.v2 --install
go get -v $(GOTOOLS)

update_tools:
@echo "--> Updating tools"
@go get -u $(GOTOOLS)

get_vendor_deps:
@rm -rf vendor/
@echo "--> Running dep ensure"
@dep ensure
@go get -u -v $(GOTOOLS)


########################################
Expand Down Expand Up @@ -66,46 +59,12 @@ gofuzz_json:
fmt:
@go fmt ./...

metalinter:
@echo "==> Running linter"
gometalinter.v2 --vendor --deadline=600s --disable-all \
--enable=deadcode \
--enable=goconst \
--enable=goimports \
--enable=gosimple \
--enable=ineffassign \
--enable=megacheck \
--enable=misspell \
--enable=staticcheck \
--enable=safesql \
--enable=structcheck \
--enable=unconvert \
--enable=unused \
--enable=varcheck \
--enable=vetshadow \
./...

#--enable=maligned \
#--enable=gas \
#--enable=aligncheck \
#--enable=dupl \
#--enable=errcheck \
#--enable=gocyclo \
#--enable=golint \ <== comments on anything exported
#--enable=gotype \
#--enable=interfacer \
#--enable=unparam \
#--enable=vet \

metalinter_all:
protoc $(INCLUDE) --lint_out=. types/*.proto
gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...


test_golang1.10rc:
docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/go-amino" -w "/go/src/github.com/tendermint/go-amino" golang:1.10-rc /bin/bash -ci "make get_tools all"
# look into .golangci.yml for enabling / disabling linters
lint:
@echo "--> Running linter"
@golangci-lint run

# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build install check_tools get_tools update_tools get_vendor_deps test fmt metalinter metalinter_all
.PHONY: build install check_tools get_tools fmt lint test
4 changes: 2 additions & 2 deletions binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestStructPointerSlice1(t *testing.T) {
var f3 = Foo{
A: "k",
B: 2,
C: []*Foo{&Foo{}, &Foo{}, &Foo{}},
C: []*Foo{{}, {}, {}},
D: "j",
}
bz2, err := cdc.MarshalBinaryLengthPrefixed(f3)
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestStructPointerSlice2(t *testing.T) {
bz, err := cdc.MarshalBinaryLengthPrefixed(f)
assert.Error(t, err, "nil elements of a slice/array not supported when empty_elements field tag set.")

f.C = []*Foo{&Foo{}, &Foo{}, &Foo{}}
f.C = []*Foo{{}, {}, {}}
bz, err = cdc.MarshalBinaryLengthPrefixed(f)
assert.NoError(t, err)

Expand Down
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/tendermint/go-amino

go 1.12

require (
github.com/davecgh/go-spew v1.1.1
github.com/golang/protobuf v1.3.0
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
github.com/stretchr/testify v1.3.0
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect
)
18 changes: 18 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
Loading