Merge pull request #51722 from vvoland/modernize

Modernize Go code
This commit is contained in:
Paweł Gronowski
2025-12-16 12:38:36 +00:00
committed by GitHub
157 changed files with 464 additions and 633 deletions

View File

@@ -1593,7 +1593,7 @@ func checkProxies(ctx context.Context, t *testing.T, c *client.Client, daemonPid
t.Error(res)
return
}
for _, line := range strings.Split(res.Stdout(), "\n") {
for line := range strings.SplitSeq(res.Stdout(), "\n") {
_, args, ok := strings.Cut(line, "docker-proxy")
if !ok {
continue
@@ -1787,7 +1787,7 @@ func TestAdvertiseAddresses(t *testing.T) {
// the associated MAC address.
findNeighMAC := func(neighOut, ip string) string {
t.Helper()
for _, line := range strings.Split(neighOut, "\n") {
for line := range strings.SplitSeq(neighOut, "\n") {
// Lines look like ...
// 172.22.22.22 dev eth0 lladdr 36:bc:ce:67:f3:e4 ref 1 used 0/7/0 probes 1 DELAY
fields := strings.Fields(line)
@@ -2017,7 +2017,7 @@ func TestLegacyLinksEnvVars(t *testing.T) {
// Check the list of environment variables set in the linking container.
var found bool
for _, l := range strings.Split(exportRes.Stdout.String(), "\n") {
for l := range strings.SplitSeq(exportRes.Stdout.String(), "\n") {
if strings.HasPrefix(l, "export CTR1_") {
// Legacy links env var found, but not expected.
if !tc.expectEnvVars {

View File

@@ -281,8 +281,8 @@ func enableIPv6OnAll(t *testing.T) func() {
ifaces := map[string]string{}
var allVal string
sysctls := strings.Split(string(out), "\n")
for _, sysctl := range sysctls {
sysctls := strings.SplitSeq(string(out), "\n")
for sysctl := range sysctls {
if sysctl == "" {
continue
}
@@ -1470,7 +1470,7 @@ func TestAccessPortPublishedOnLoopbackAddress(t *testing.T) {
func sendPayloadFromHost(t *testing.T, host networking.Host, daddr, dport, payload string, check func() bool) bool {
var res bool
host.Do(t, func() {
for i := 0; i < 10; i++ {
for i := range 10 {
t.Logf("Sending probe #%d to %s:%s from host %s", i, daddr, dport, host.Name)
icmd.RunCommand("/bin/sh", "-c", fmt.Sprintf("echo '%s' | nc -w1 -u %s %s", payload, daddr, dport)).Assert(t, icmd.Success)