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

cmd/go: go test -json has inconsistent Time precision #44588

rittneje opened this issue Feb 24, 2021 · 0 comments

cmd/go: go test -json has inconsistent Time precision #44588

rittneje opened this issue Feb 24, 2021 · 0 comments
GoCommand NeedsInvestigation


Copy link

@rittneje rittneje commented Feb 24, 2021

What version of Go are you using (go version)?

$ go version
go version go1.14.13 darwin/amd64

Does this issue reproduce with the latest release?

Yes (go1.16)

What did you do?

Ran go test -json on a package, and attempted to sort the resulting JSON via jq using the Package and Time fields.

What did you expect to see?

I expected jq to sort the results correctly.

What did you see instead?

I noticed that the decimal precision of the Time field is inconsistent. My guess is that it is chopping off trailing zeros. However, this means that the resulting timestamps cannot be sorted properly. For example, we might get the following two entries:

{"Time":"2021-02-24T14:14:25.8589Z","Action":"output","Package":"my-package","Test":"TestFoo","Output":"=== RUN TestFoo\n"}
{"Time":"2021-02-24T14:14:25.8589131Z","Action":"output","Package":"my-package","Test":"TestFoo","Output":" --- PASS: TestFoo (0.00s)\n"}

Since 'Z' > '1', this causes the "PASS" line to get sorted before the "RUN" line. This is especially a problem when dealing with older (< 1.6) versions of jq that do not perform a stable sort.

@seankhliao seankhliao added GoCommand NeedsInvestigation labels Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
GoCommand NeedsInvestigation
None yet

No branches or pull requests

2 participants