Skip to content

Commit

Permalink
Merge pull request #271 from tendermint/develop
Browse files Browse the repository at this point in the history
Merge develop into master:
- to tag and release v0.15.0 on master
- to delete develop after that
  • Loading branch information
liamsi authored May 15, 2019
2 parents dc14acf + a159742 commit 6423ac6
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 109 deletions.
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.15.0 (May 2, 2018)

BREAKING CHANGE:
- JSON: Skip null fields on decoding when the `json:"omitempty"` tag is set.
This matches the encoding behaviour ([#261]).

IMPROVEMENTS:
- Amino becomes a go-module (requires go 1.11) but keeps dep support for backwards compatibility ([#255]).


[#255]: https://github.com/tendermint/go-amino/pull/255
[#261]: https://github.com/tendermint/go-amino/issues/261

## 0.14.1 (November 6, 2018)

IMPROVEMENTS:
Expand Down
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
71 changes: 16 additions & 55 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 All @@ -49,15 +42,17 @@ gofuzz_binary:
rm -rf tests/fuzz/binary/crashers/
rm -rf tests/fuzz/binary/suppressions/
go run tests/fuzz/binary/init-corpus/main.go --corpus-parent=tests/fuzz/binary
go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/binary
go-fuzz -bin=./fuzz_binary-fuzz.zip -workdir=tests/fuzz/binary
# TODO: update when https://github.com/dvyukov/go-fuzz/issues/195 is resolved
GO111MODULE=off go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/binary
GO111MODULE=off go-fuzz -bin=./fuzz_binary-fuzz.zip -workdir=tests/fuzz/binary

gofuzz_json:
rm -rf tests/fuzz/json/corpus/
rm -rf tests/fuzz/json/crashers/
rm -rf tests/fuzz/json/suppressions/
go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/json
go-fuzz -bin=./fuzz_json-fuzz.zip -workdir=tests/fuzz/json
# TODO: update when https://github.com/dvyukov/go-fuzz/issues/195 is resolved
GO111MODULE=off go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/json
GO111MODULE=off go-fuzz -bin=./fuzz_json-fuzz.zip -workdir=tests/fuzz/json


########################################
Expand All @@ -66,46 +61,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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ duplication and help streamline development from inception to maturity.
## Amino in the Wild

* Amino:binary spec in [Tendermint](
https://github.com/tendermint/tendermint/blob/develop/docs/specification/new-spec/encoding.md)
https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/encoding.md)


# Amino Spec
Expand Down
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=
8 changes: 6 additions & 2 deletions json-decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,12 @@ func (cdc *Codec) decodeReflectJSONStruct(bz []byte, info *TypeInfo, rv reflect.
// but perhaps we are aiming for as much compatibility here.
// JAE: I vote we depart from encoding/json, than carry a vuln.

// Set nil/zero on frv.
frv.Set(reflect.Zero(frv.Type()))
// Set to the zero value only if not omitempty
if !field.JSONOmitEmpty {
// Set nil/zero on frv.
frv.Set(reflect.Zero(frv.Type()))
}

continue
}

Expand Down
Loading

0 comments on commit 6423ac6

Please sign in to comment.