Skip to content

Commit

Permalink
github.com/pborman/uuid -> github.com/google/uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
pebbe committed Mar 24, 2021
1 parent 2e4d126 commit 511c6cb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.16
replace github.com/pebbe/zmq4 => ../

require (
github.com/pborman/uuid v1.2.1
github.com/pebbe/zmq4 v0.0.0-00010101000000-000000000000 // indirect
github.com/google/uuid v1.0.0
github.com/pebbe/zmq4 v0.0.0-00010101000000-000000000000
)
2 changes: 0 additions & 2 deletions examples/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
21 changes: 12 additions & 9 deletions examples/intface/intface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package intface
import (
zmq "github.com/pebbe/zmq4"

"github.com/pborman/uuid"
"github.com/google/uuid"

"bytes"
"errors"
Expand Down Expand Up @@ -73,8 +73,9 @@ const (
// We have a constructor for the peer class:

func new_peer(uuid uuid.UUID) (peer *peer_t) {
uuid_bytes, _ := uuid.MarshalBinary()
peer = &peer_t{
uuid_bytes: []byte(uuid),
uuid_bytes: uuid_bytes,
uuid_string: uuid.String(),
}
return
Expand Down Expand Up @@ -127,13 +128,14 @@ func new_agent() (agent *agent_t) {
udp, _ := zmq.NewSocket(zmq.PAIR)
udp.Connect("inproc://udp")

uuid := uuid.NewRandom()
uuID := uuid.New()
uuid_bytes, _ := uuID.MarshalBinary()
agent = &agent_t{
pipe: pipe,
udp: udp,
conn: conn,
uuid_bytes: []byte(uuid),
uuid_string: uuid.String(),
uuid_bytes: uuid_bytes,
uuid_string: uuID.String(),
peers: make(map[string]*peer_t),
}

Expand Down Expand Up @@ -172,13 +174,14 @@ func (agent *agent_t) handle_beacon() (err error) {
}

// If we got a UUID and it's not our own beacon, we have a peer
uuid := uuid.UUID(msg[0])
if bytes.Compare(uuid, agent.uuid_bytes) != 0 {
uuid_bytes := []byte(msg[0])
if bytes.Compare(uuid_bytes, agent.uuid_bytes) != 0 {
// Find or create peer via its UUID string
uuid_string := uuid.String()
uuID, _ := uuid.ParseBytes(uuid_bytes)
uuid_string := uuID.String()
peer, ok := agent.peers[uuid_string]
if !ok {
peer = new_peer(uuid)
peer = new_peer(uuID)
agent.peers[uuid_string] = peer

// Report peer joined the network
Expand Down
5 changes: 3 additions & 2 deletions examples/kvmsg/kvmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package kvmsg
import (
zmq "github.com/pebbe/zmq4"

"github.com/pborman/uuid"
"github.com/google/uuid"

"errors"
"fmt"
Expand Down Expand Up @@ -185,7 +185,8 @@ func (kvmsg *Kvmsg) GetUuid() (uuid string, err error) {

// Sets the UUID to a random generated value
func (kvmsg *Kvmsg) SetUuid() {
kvmsg.frame[frame_UUID] = string(uuid.NewRandom()) // raw 16 bytes
b, _ := uuid.New().MarshalBinary()
kvmsg.frame[frame_UUID] = string(b) // raw 16 bytes
kvmsg.present[frame_UUID] = true

}
Expand Down
4 changes: 2 additions & 2 deletions examples/titanic.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package main
import (
"github.com/pebbe/zmq4/examples/mdapi"

"github.com/pborman/uuid"
"github.com/google/uuid"

"fmt"
"io/ioutil"
Expand Down Expand Up @@ -53,7 +53,7 @@ func TitanicRequest(chRequest chan<- string) {
os.MkdirAll(TITANIC_DIR, 0700)

// Generate UUID and save message to disk
uuid := uuid.New()
uuid := uuid.New().String()
file, err := os.Create(RequestFilename(uuid))
fmt.Fprint(file, strings.Join(request, "\n"))
file.Close()
Expand Down

0 comments on commit 511c6cb

Please sign in to comment.