mirror of
https://github.com/redis/go-redis.git
synced 2025-07-31 05:04:23 +03:00
feat(scan): scan time.Time sets the default decoding (#2413)
* feat(scan): scan time.Time uses `UnmarshalText(RFC3339)` interface decoding by default
This commit is contained in:
@ -200,4 +200,16 @@ var _ = Describe("Scan", func() {
|
||||
Expect(td.Time.UnixNano()).To(Equal(now.UnixNano()))
|
||||
Expect(td.Time.Format(time.RFC3339Nano)).To(Equal(now.Format(time.RFC3339Nano)))
|
||||
})
|
||||
|
||||
It("should time.Time RFC3339Nano", func() {
|
||||
type TimeTime struct {
|
||||
Time time.Time `redis:"time"`
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var tt TimeTime
|
||||
Expect(Scan(&tt, i{"time"}, i{now.Format(time.RFC3339Nano)})).NotTo(HaveOccurred())
|
||||
Expect(now.Unix()).To(Equal(tt.Time.Unix()))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user