diff --git a/.travis.yml b/.travis.yml index 7789141..0ececa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,11 @@ language: go go: - tip + - stable + +matrix: + allow_failures: + - go: tip + install: - - go get github.com/ugorji/go/codec - - go get github.com/pquerna/ffjson/fflib/v1 - - go get github.com/json-iterator/go - go get golang.org/x/lint/golint diff --git a/Makefile b/Makefile index 1604dfa..2938f0f 100644 --- a/Makefile +++ b/Makefile @@ -1,64 +1,56 @@ -PKG=github.com/mailru/easyjson -GOPATH:=$(PWD)/.root:$(GOPATH) -export GOPATH - all: test -.root/src/$(PKG): - mkdir -p $@ - for i in $$PWD/* ; do ln -s $$i $@/`basename $$i` ; done - -root: .root/src/$(PKG) - clean: rm -rf .root rm -rf tests/*_easyjson.go + rm -rf benchmark/*_easyjson.go build: - go build -i -o .root/bin/easyjson $(PKG)/easyjson + go build -i -o .root/bin/easyjson ./easyjson -generate: root build +generate: build .root/bin/easyjson -stubs \ - .root/src/$(PKG)/tests/snake.go \ - .root/src/$(PKG)/tests/data.go \ - .root/src/$(PKG)/tests/omitempty.go \ - .root/src/$(PKG)/tests/nothing.go \ - .root/src/$(PKG)/tests/named_type.go \ - .root/src/$(PKG)/tests/custom_map_key_type.go \ - .root/src/$(PKG)/tests/embedded_type.go \ - .root/src/$(PKG)/tests/reference_to_pointer.go \ + ./tests/snake.go \ + ./tests/data.go \ + ./tests/omitempty.go \ + ./tests/nothing.go \ + ./tests/named_type.go \ + ./tests/custom_map_key_type.go \ + ./tests/embedded_type.go \ + ./tests/reference_to_pointer.go \ - .root/bin/easyjson -all .root/src/$(PKG)/tests/data.go - .root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go - .root/bin/easyjson -all .root/src/$(PKG)/tests/errors.go - .root/bin/easyjson -snake_case .root/src/$(PKG)/tests/snake.go - .root/bin/easyjson -omit_empty .root/src/$(PKG)/tests/omitempty.go - .root/bin/easyjson -build_tags=use_easyjson .root/src/$(PKG)/benchmark/data.go - .root/bin/easyjson .root/src/$(PKG)/tests/nested_easy.go - .root/bin/easyjson .root/src/$(PKG)/tests/named_type.go - .root/bin/easyjson .root/src/$(PKG)/tests/custom_map_key_type.go - .root/bin/easyjson .root/src/$(PKG)/tests/embedded_type.go - .root/bin/easyjson .root/src/$(PKG)/tests/reference_to_pointer.go - .root/bin/easyjson .root/src/$(PKG)/tests/key_marshaler_map.go - .root/bin/easyjson -disallow_unknown_fields .root/src/$(PKG)/tests/disallow_unknown.go + .root/bin/easyjson -all ./tests/data.go + .root/bin/easyjson -all ./tests/nothing.go + .root/bin/easyjson -all ./tests/errors.go + .root/bin/easyjson -snake_case ./tests/snake.go + .root/bin/easyjson -omit_empty ./tests/omitempty.go + .root/bin/easyjson -build_tags=use_easyjson ./benchmark/data.go + .root/bin/easyjson ./tests/nested_easy.go + .root/bin/easyjson ./tests/named_type.go + .root/bin/easyjson ./tests/custom_map_key_type.go + .root/bin/easyjson ./tests/embedded_type.go + .root/bin/easyjson ./tests/reference_to_pointer.go + .root/bin/easyjson ./tests/key_marshaler_map.go + .root/bin/easyjson -disallow_unknown_fields ./tests/disallow_unknown.go -test: generate root +test: generate go test \ - $(PKG)/tests \ - $(PKG)/jlexer \ - $(PKG)/gen \ - $(PKG)/buffer - go test -benchmem -tags use_easyjson -bench . $(PKG)/benchmark - golint -set_exit_status .root/src/$(PKG)/tests/*_easyjson.go + ./tests \ + ./jlexer \ + ./gen \ + ./buffer + cd benchmark && go test -benchmem -tags use_easyjson -bench . + golint -set_exit_status ./tests/*_easyjson.go -bench-other: generate root - @go test -benchmem -bench . $(PKG)/benchmark - @go test -benchmem -tags use_ffjson -bench . $(PKG)/benchmark - @go test -benchmem -tags use_jsoniter -bench . $(PKG)/benchmark - @go test -benchmem -tags use_codec -bench . $(PKG)/benchmark +bench-other: generate + cd benchmark + @go test -benchmem -bench . + @go test -benchmem -tags use_ffjson -bench . + @go test -benchmem -tags use_jsoniter -bench . + @go test -benchmem -tags use_codec -bench . bench-python: benchmark/ujson.sh -.PHONY: root clean generate test build +.PHONY: clean generate test build diff --git a/benchmark/go.mod b/benchmark/go.mod new file mode 100644 index 0000000..72e3fdf --- /dev/null +++ b/benchmark/go.mod @@ -0,0 +1,12 @@ +module github.com/mailru/easyjson/benchmark + +go 1.12 + +require ( + github.com/json-iterator/go v1.1.7 + github.com/mailru/easyjson v0.0.0 + github.com/pquerna/ffjson v0.0.0-20190813045741-dac163c6c0a9 + github.com/ugorji/go/codec v1.1.7 +) + +replace github.com/mailru/easyjson => ../ diff --git a/benchmark/go.sum b/benchmark/go.sum new file mode 100644 index 0000000..f2a0ff9 --- /dev/null +++ b/benchmark/go.sum @@ -0,0 +1,21 @@ +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/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +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/pquerna/ffjson v0.0.0-20190813045741-dac163c6c0a9 h1:kyf9snWXHvQc+yxE9imhdI8YAm4oKeZISlaAR+x73zs= +github.com/pquerna/ffjson v0.0.0-20190813045741-dac163c6c0a9/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= +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= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7bc4a65 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/mailru/easyjson + +go 1.12