Skip to content
Closed
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
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module resty.dev/v3
module github.com/digitalmint/resty/v4

go 1.21
go 1.23.0

require golang.org/x/net v0.33.0
toolchain go1.24.5

require golang.org/x/net v0.42.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
2 changes: 1 addition & 1 deletion resty.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT

// Package resty provides Simple HTTP, REST, and SSE client library for Go.
package resty // import "resty.dev/v3"
package resty

import (
"math"
Expand Down
13 changes: 5 additions & 8 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package resty

import (
"bytes"
"crypto/md5"
"crypto/rand"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"errors"
Expand Down Expand Up @@ -403,21 +403,18 @@ var osHostname = os.Hostname
// readMachineID generates and returns a machine id.
// If this function fails to get the hostname it will cause a runtime error.
func readMachineID() []byte {
var sum [3]byte
id := sum[:]
const idSize = 3
id := make([]byte, idSize)

if hostname, err := osHostname(); err == nil {
hw := md5.New()
_, _ = hw.Write([]byte(hostname))
copy(id, hw.Sum(nil))
hash := sha256.Sum256([]byte(hostname))
copy(id, hash[:idSize])
return id
}

if _, err := ioReadFull(rand.Reader, id); err == nil {
return id
}

// To initialize package unexported variable 'machineID'.
// This panic would happen at program startup, so no worries at runtime panic.
panic(errors.New("resty - guid: unable to get hostname and random bytes"))
}