diff --git a/go.mod b/go.mod index 2459ace0..4e679733 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 9a366fbf..d46c06a2 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 96880304..b983d011 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 4af89487..c610c591 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 cd8b5fd4..78be6a2a 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 e2f61255..520cce08 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