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

JSON tests fail on Go 1.13 #43

Closed
Fenny opened this issue Sep 8, 2020 · 3 comments · Fixed by #46
Closed

JSON tests fail on Go 1.13 #43

Fenny opened this issue Sep 8, 2020 · 3 comments · Fixed by #46

Comments

@Fenny
Copy link
Contributor

Fenny commented Sep 8, 2020

Hi @achille-roussel, first I want to say you did an awesome job with this library 💯

According to the go.mod file this package should be compatible with Go 1.13, but when I run go test ./... -v -race on this version it seems to fail. Should this be correct since we are only testing on Go 1.14 https://github.com/segmentio/encoding/blob/master/.circleci/config.yml#L5?

=== RUN   TestCompact
--- FAIL: TestCompact (0.00s)
##[error]    golang_scanner_test.go:73: Compact(`{"":"<>&

"}`) = `{"":"<>&\u2028\u2029"}`, want original
##[error]    golang_scanner_test.go:81: Compact("{\n\t\"\": \"<>&\u2028\u2029\"\n}") = `{"":"<>&\u2028\u2029"}`, want `{"":"<>&

"}`
=== RUN   TestCompactSeparators
--- FAIL: TestCompactSeparators (0.00s)
##[error]    golang_scanner_test.go:100: Compact("{\"\u2028\": 1}") = "{\"\\u2028\":1}", want "{\"\u2028\":1}"
##[error]    golang_scanner_test.go:100: Compact("{\"\u2029\" :2}") = "{\"\\u2029\":2}", want "{\"\u2029\":2}"

=== RUN   TestGithubIssue11
--- PASS: TestGithubIssue11 (0.00s)
##[error]    json_test.go:1228: json: unsupported value: NaN
=== RUN   TestGithubIssue13
--- PASS: TestGithubIssue13 (0.00s)
##[error]    json_test.go:1249: {"Stringer":null,"MyInt":0}

--- PASS: TestDecodeLines (0.00s)
    --- PASS: TestDecodeLines/bare_object (0.00s)
    --- PASS: TestDecodeLines/multiple_objects_on_one_line (0.00s)
    --- PASS: TestDecodeLines/object_spanning_multiple_lines (0.00s)
    --- PASS: TestDecodeLines/trailing_newline (0.00s)
    --- PASS: TestDecodeLines/multiple_trailing_newlines (0.00s)
    --- PASS: TestDecodeLines/blank_lines (0.00s)
    --- PASS: TestDecodeLines/no_trailing_newline (0.00s)
    --- PASS: TestDecodeLines/leading_whitespace (0.00s)
    --- PASS: TestDecodeLines/one_object,_multiple_reads (0.00s)
    --- PASS: TestDecodeLines/one_object_+_EOF (0.00s)
    --- PASS: TestDecodeLines/leading_whitespace_+_EOF (0.00s)
    --- PASS: TestDecodeLines/multiple_objects_+_EOF (0.00s)
    --- PASS: TestDecodeLines/one_object_+_multiple_reads_+_EOF (0.00s)
    --- PASS: TestDecodeLines/multiple_objects_+_multiple_reads_+_EOF (0.00s)
    --- PASS: TestDecodeLines/unmarshal_error_while_decoding (0.00s)
##[error]        json_test.go:735: unmarshal error json: cannot unmarshal "42}" into Go struct field json.obj.Good. of type bool
    --- PASS: TestDecodeLines/unmarshal_error_while_decoding_last_object (0.00s)
##[error]        json_test.go:735: unmarshal error json: cannot unmarshal "42}" into Go struct field json.obj.Good. of type bool
@Fenny Fenny changed the title JSON test fails on v1.13 JSON test fails on Go 1.13 Sep 8, 2020
@Fenny Fenny changed the title JSON test fails on Go 1.13 JSON tests fail on Go 1.13 Sep 8, 2020
@abraithwaite
Copy link

abraithwaite commented Sep 8, 2020

This is a result of this change in Go1.14:

https://golang.org/doc/go1.14#encoding/json

Unfortunately, Go1.13 is now deprecated with the release of Go1.15. I could be wrong, but I believe we're taking the same approach around deprecation timelines, so (understanding I haven't read the code for this issue) I think it's unlikely to be fixed.

Is there something keeping you on Go1.13 in particular?

Edit: reading more closely, it seems like this ticket is more about Go1.13 being listed as supported by the Go mod file. Seems reasonable that we should probably bump that if this is our stance.

@achille-roussel
Copy link
Contributor

achille-roussel commented Sep 8, 2020

The reason the tests failed is because there was a behavior change in encoding/json in Go 1.14 that we ported to this project (see #34).

The path forward should be to update go.mod to require Go 1.14 (like @abraithwaite suggested), if you want to remain on Go 1.13 you should use segmentio/encoding v0.1.10 (although that may not be a great option since it means giving up on some bug fixes).

@Fenny
Copy link
Contributor Author

Fenny commented Sep 8, 2020

There is no particular reason to use 1.13, but if it means it's not cross-compatible with other projects that run on 1.11 or higher for example. I think we should adjust the go.mod, I can make a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants