Skip to content
This repository was archived by the owner on Sep 29, 2024. It is now read-only.

Commit c249f7c

Browse files
authored
Merge pull request #441 from hvquy001/master
fix: uuid.NewV4() in single-value context error by change to use github.com/gofrs/uuid
2 parents 4ba97de + bc0cd32 commit c249f7c

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/davecgh/go-spew v1.1.1 // indirect
77
github.com/gomodule/redigo v1.8.4
88
github.com/gorilla/websocket v1.4.2
9-
github.com/satori/go.uuid v1.2.0
9+
github.com/gofrs/uuid v4.0.0+incompatible
1010
github.com/stretchr/testify v1.5.1
1111
gopkg.in/yaml.v2 v2.2.4 // indirect
1212
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
6+
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
57
github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc=
68
github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
79
github.com/gomodule/redigo v1.8.4 h1:Z5JUg94HMTR1XpwBaSH4vq3+PNSIykBLxMdglbw10gg=

helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package socketio
2+
3+
import "github.com/gofrs/uuid"
4+
5+
func newV4UUID() string {
6+
return uuid.Must(uuid.NewV4()).String()
7+
}

redis_broadcast.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"sync"
88

99
"github.com/gomodule/redigo/redis"
10-
uuid "github.com/satori/go.uuid"
1110
)
1211

1312
// RedisAdapterOptions is configuration to create new adapter
@@ -123,7 +122,7 @@ func newRedisBroadcast(nsp string, adapter *RedisAdapterOptions) (*redisBroadcas
123122
bc.sub = redis.PubSubConn{Conn: sub}
124123

125124
bc.nsp = nsp
126-
bc.uid = uuid.NewV4().String()
125+
bc.uid = newV4UUID()
127126
bc.key = bc.prefix + "#" + bc.nsp + "#" + bc.uid
128127
bc.reqChannel = bc.prefix + "-request#" + bc.nsp
129128
bc.resChannel = bc.prefix + "-response#" + bc.nsp
@@ -355,7 +354,7 @@ func (bc *redisBroadcast) Clear(room string) {
355354
func (bc *redisBroadcast) publishClear(room string) {
356355
req := clearRoomRequest{
357356
RequestType: clearRoomReqType,
358-
RequestID: uuid.NewV4().String(),
357+
RequestID: newV4UUID(),
359358
Room: room,
360359
UUID: bc.uid,
361360
}
@@ -456,7 +455,7 @@ func (bc *redisBroadcast) Len(room string) int {
456455

457456
req := roomLenRequest{
458457
RequestType: roomLenReqType,
459-
RequestID: uuid.NewV4().String(),
458+
RequestID: newV4UUID(),
460459
Room: room,
461460
}
462461

@@ -494,7 +493,7 @@ func (bc *redisBroadcast) AllRooms() []string {
494493

495494
req := allRoomRequest{
496495
RequestType: allRoomReqType,
497-
RequestID: uuid.NewV4().String(),
496+
RequestID: newV4UUID(),
498497
}
499498
reqJSON, _ := json.Marshal(&req)
500499

0 commit comments

Comments
 (0)