Skip to content

Commit 027188b

Browse files
committed
added omitempty
1 parent 9adc3ca commit 027188b

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

example/hset-struct/go.mod

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module github.com/redis/go-redis/example/scan-struct
2+
3+
go 1.18
4+
5+
replace github.com/redis/go-redis/v9 => ../..
6+
7+
require (
8+
github.com/davecgh/go-spew v1.1.1
9+
github.com/redis/go-redis/v9 v9.6.2
10+
)
11+
12+
require (
13+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
14+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
15+
)

example/hset-struct/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
2+
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
3+
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
4+
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5+
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
6+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
7+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
10+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=

example/hset-struct/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Model struct {
2121
Bool bool `redis:"bool"`
2222
Bool2 *bool `redis:"bool2"`
2323
Bool3 *bool `redis:"bool3"`
24+
Bool4 *bool `redis:"bool4,omitempty"`
2425
Time time.Time `redis:"time"`
2526
Time2 *time.Time `redis:"time2"`
2627
Time3 *time.Time `redis:"time3"`
@@ -31,7 +32,8 @@ func main() {
3132
ctx := context.Background()
3233

3334
rdb := redis.NewClient(&redis.Options{
34-
Addr: ":6379",
35+
Addr: ":6379",
36+
Password: "Mafia1234",
3537
})
3638
_ = rdb.FlushDB(ctx).Err()
3739

@@ -91,6 +93,7 @@ func main() {
9193
// Bool: (bool) true,
9294
// Bool2: (*bool)(0xc000014570)(false),
9395
// Bool3: (*bool)(0xc000014548)(false),
96+
// Bool4: (*bool)(<nil>),
9497
// Time: (time.Time) 2025-02-08 00:00:00 +0000 UTC,
9598
// Time2: (*time.Time)(0xc0000122a0)(2025-02-08 00:00:00 +0000 UTC),
9699
// Time3: (*time.Time)(0xc000012288)(0001-01-01 00:00:00 +0000 UTC),
@@ -112,6 +115,7 @@ func main() {
112115
// Bool: (bool) false,
113116
// Bool2: (*bool)(<nil>),
114117
// Bool3: (*bool)(<nil>),
118+
// Bool4: (*bool)(<nil>),
115119
// Time: (time.Time) 0001-01-01 00:00:00 +0000 UTC,
116120
// Time2: (*time.Time)(<nil>),
117121
// Time3: (*time.Time)(<nil>),

example/scan-struct/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
22
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
33
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
44
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
56
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
67
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
78
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=

internal/proto/writer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ func (w *Writer) WriteArg(v interface{}) error {
170170
}
171171
return w.int(0)
172172
case time.Time:
173-
fmt.Println("writing time")
174173
w.numBuf = v.AppendFormat(w.numBuf[:0], time.RFC3339Nano)
175174
return w.bytes(w.numBuf)
176175
case *time.Time:

0 commit comments

Comments
 (0)