We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Please answer these questions before submitting your issue. Thanks!
go version
go1.9.2 linux/amd64
yes
go env
ubuntu
go test follow file
package simple_struct import ( "time" "encoding/json" "github.com/stretchr/testify/assert" "testing" ) type SimpleStruct struct { CreateTime time.Time Other string } func NewSimpleStruct() *SimpleStruct { return &SimpleStruct{ CreateTime: time.Now(), } } func Test(t *testing.T) { s1 := NewSimpleStruct() data, err := json.Marshal(s1) assert.Nil(t, err) s2 := &SimpleStruct{} err = json.Unmarshal(data, s2) assert.Nil(t, err) assert.Equal(t, s2, s1) // work in golang 1.8, but golang 1.9 }
The text was updated successfully, but these errors were encountered:
Error Trace: simple_test.go:28 Error: Not equal: expected: &simple_struct.SimpleStruct{CreateTime:time.Time{wall:0x1e13a63e, ext:63647709442, loc:(*time.Location)(0x871cc0)}, Other:""} actual: &simple_struct.SimpleStruct{CreateTime:time.Time{wall:0xbe805e609e13a63e, ext:2691802, loc:(*time.Location)(0x871cc0)}, Other:""} Diff: --- Expected +++ Actual @@ -1,3 +1,3 @@ (*simple_struct.SimpleStruct)({ - CreateTime: (time.Time) 2017-12-01 15:17:22.504604222 +0800 CST, + CreateTime: (time.Time) 2017-12-01 15:17:22.504604222 +0800 CST m=+0.002691802,
Sorry, something went wrong.
Yes, this was the change to time.Time in Go 1.9. You'll need to update your test to not test so deeply.
See: https://golang.org/doc/go1.9#monotonic-time https://golang.org/pkg/time/#hdr-Monotonic_Clocks
Notably, this part:
The canonical way to strip a monotonic clock reading is to use t = t.Round(0).
Alternatively, for less brittle comparisons, see: https://github.com/google/go-cmp
thanks
No branches or pull requests
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?ubuntu
go test follow file
The text was updated successfully, but these errors were encountered: