From 9be976c269395f3689e8da435cf2370af600bad3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 23 Mar 2026 17:34:26 +0100 Subject: [PATCH] update minimum go version to go1.23 Signed-off-by: Sebastiaan van Stijn --- go.mod | 2 +- nat/nat.go | 2 +- nat/sort.go | 1 - nat/sort_test.go | 2 +- proxy/logger.go | 4 ++-- tlsconfig/config_test.go | 4 ++-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 2459ace0d..4e6797333 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/docker/go-connections -go 1.18 +go 1.23 require ( github.com/Microsoft/go-winio v0.4.21 diff --git a/nat/nat.go b/nat/nat.go index 9a366fbf5..d46c06a27 100644 --- a/nat/nat.go +++ b/nat/nat.go @@ -218,7 +218,7 @@ func ParsePortSpec(rawPort string) ([]PortMapping, error) { count := endPort - startPort + 1 ports := make([]PortMapping, 0, count) - for i := 0; i < count; i++ { + for i := range count { hPort := "" if hostPort != "" { hPort = strconv.Itoa(startHostPort + i) diff --git a/nat/sort.go b/nat/sort.go index 968803041..b983d0114 100644 --- a/nat/sort.go +++ b/nat/sort.go @@ -69,7 +69,6 @@ func SortPortMap(ports []Port, bindings map[Port][]PortBinding) { portInt, portProto := p.Int(), p.Proto() if binding, ok := bindings[p]; ok && len(binding) > 0 { for _, b := range binding { - b := b // capture loop variable for go < 1.22 s = append(s, portMapEntry{ port: p, binding: &b, portInt: portInt, portProto: portProto, diff --git a/nat/sort_test.go b/nat/sort_test.go index 4af89487c..c610c591c 100644 --- a/nat/sort_test.go +++ b/nat/sort_test.go @@ -83,7 +83,7 @@ func BenchmarkSortPortMap(b *testing.B) { ports := make([]Port, 0, n*2) portMap := make(map[Port][]PortBinding, n*2) - for i := 0; i < n; i++ { + for i := range n { portNum := 30000 + (i % 50) // force duplicate port numbers tcp := Port(fmt.Sprintf("%d/tcp", portNum)) udp := Port(fmt.Sprintf("%d/udp", portNum)) diff --git a/proxy/logger.go b/proxy/logger.go index cd8b5fd48..78be6a2a2 100644 --- a/proxy/logger.go +++ b/proxy/logger.go @@ -1,11 +1,11 @@ package proxy type logger interface { - Printf(format string, args ...interface{}) + Printf(format string, args ...any) } type noopLogger struct{} -func (l *noopLogger) Printf(_ string, _ ...interface{}) { +func (l *noopLogger) Printf(_ string, _ ...any) { // Do nothing :) } diff --git a/tlsconfig/config_test.go b/tlsconfig/config_test.go index e2f612558..520cce083 100644 --- a/tlsconfig/config_test.go +++ b/tlsconfig/config_test.go @@ -77,7 +77,7 @@ func TestConfigServerTLSFailsIfUnableToLoadCerts(t *testing.T) { _ = tempFile.Close() for _, badFile := range []string{"not-a-file", tempFile.Name()} { - for i := 0; i < 3; i++ { + for i := range 3 { files := []string{cert, key, ca} files[i] = badFile @@ -475,7 +475,7 @@ func TestConfigClientTLSClientCertOrKeyInvalid(t *testing.T) { defer func() { _ = os.Remove(tempFile.Name()) }() _ = tempFile.Close() - for i := 0; i < 2; i++ { + for i := range 2 { for _, invalid := range []string{"not-a-file", "", tempFile.Name()} { files := []string{cert, key} files[i] = invalid