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

Commit

Permalink
Merge pull request #441 from hvquy001/master
Browse files Browse the repository at this point in the history
fix: uuid.NewV4() in single-value context error by change to use github.com/gofrs/uuid
  • Loading branch information
sshaplygin authored May 2, 2021
2 parents 4ba97de + bc0cd32 commit c249f7c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
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

0 comments on commit c249f7c

Please sign in to comment.