Skip to content

Commit 748e2a7

Browse files
committed
fix: revert go mod compat for sdk,api to 1.19
1 parent 15d2684 commit 748e2a7

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hashicorp/consul/api
22

3-
go 1.20
3+
go 1.19
44

55
replace github.com/hashicorp/consul/sdk => ../sdk
66

envoyextensions/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hashicorp/consul/envoyextensions
22

3-
go 1.20
3+
go 1.19
44

55
replace github.com/hashicorp/consul/api => ../api
66

sdk/freeport/freeport.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ var (
7676
// total is the total number of available ports in the block for use.
7777
total int
7878

79+
// seededRand is a random generator that is pre-seeded from the current time.
80+
seededRand *rand.Rand
81+
7982
// stopCh is used to signal to background goroutines to terminate. Only
8083
// really exists for the safety of reset() during unit tests.
8184
stopCh chan struct{}
@@ -114,6 +117,7 @@ func initialize() {
114117
panic("freeport: block size too big or too many blocks requested")
115118
}
116119

120+
seededRand = rand.New(rand.NewSource(time.Now().UnixNano())) // This is compatible with go 1.19 but unnecessary in >= go1.20
117121
firstPort, lockLn = alloc()
118122

119123
condNotEmpty = sync.NewCond(&mu)
@@ -255,7 +259,7 @@ func adjustMaxBlocks() (int, error) {
255259
// be automatically released when the application terminates.
256260
func alloc() (int, net.Listener) {
257261
for i := 0; i < attempts; i++ {
258-
block := int(rand.Int31n(int32(effectiveMaxBlocks)))
262+
block := int(seededRand.Int31n(int32(effectiveMaxBlocks)))
259263
firstPort := lowPort + block*blockSize
260264
ln, err := net.ListenTCP("tcp", tcpAddr("127.0.0.1", firstPort))
261265
if err != nil {

sdk/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hashicorp/consul/sdk
22

3-
go 1.20
3+
go 1.19
44

55
require (
66
github.com/hashicorp/go-cleanhttp v0.5.1

troubleshoot/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hashicorp/consul/troubleshoot
22

3-
go 1.20
3+
go 1.19
44

55
replace github.com/hashicorp/consul/api => ../api
66

0 commit comments

Comments
 (0)