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

fix uuid.NewV4() in single-value context error by change to use github.com/gofrs/uuid #441

Merged
merged 2 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gomodule/redigo v1.8.4
github.com/gorilla/websocket v1.4.2
github.com/satori/go.uuid v1.2.0
github.com/gofrs/uuid v4.0.0+incompatible
github.com/stretchr/testify v1.5.1
gopkg.in/yaml.v2 v2.2.4 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc=
github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
github.com/gomodule/redigo v1.8.4 h1:Z5JUg94HMTR1XpwBaSH4vq3+PNSIykBLxMdglbw10gg=
Expand Down
7 changes: 7 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package socketio

import "github.com/gofrs/uuid"

func newV4UUID() string {
return uuid.Must(uuid.NewV4()).String()
}
9 changes: 4 additions & 5 deletions redis_broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"sync"

"github.com/gomodule/redigo/redis"
uuid "github.com/satori/go.uuid"
)

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

bc.nsp = nsp
bc.uid = uuid.NewV4().String()
bc.uid = newV4UUID()
bc.key = bc.prefix + "#" + bc.nsp + "#" + bc.uid
bc.reqChannel = bc.prefix + "-request#" + bc.nsp
bc.resChannel = bc.prefix + "-response#" + bc.nsp
Expand Down Expand Up @@ -355,7 +354,7 @@ func (bc *redisBroadcast) Clear(room string) {
func (bc *redisBroadcast) publishClear(room string) {
req := clearRoomRequest{
RequestType: clearRoomReqType,
RequestID: uuid.NewV4().String(),
RequestID: newV4UUID(),
Room: room,
UUID: bc.uid,
}
Expand Down Expand Up @@ -456,7 +455,7 @@ func (bc *redisBroadcast) Len(room string) int {

req := roomLenRequest{
RequestType: roomLenReqType,
RequestID: uuid.NewV4().String(),
RequestID: newV4UUID(),
Room: room,
}

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

req := allRoomRequest{
RequestType: allRoomReqType,
RequestID: uuid.NewV4().String(),
RequestID: newV4UUID(),
}
reqJSON, _ := json.Marshal(&req)

Expand Down