From e6f988834d084928acd5735cde67eab5f2c77c83 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Tue, 26 May 2026 10:02:21 -0700 Subject: [PATCH] Apply go fix stringsseq rewrites to platform-specific check files Replace strings.Split + for-range-slice with strings.SplitSeq + for-range-iterator in checks_linux.go and checks_windows.go. These files are invisible to go fix on macOS (darwin build tag), so the CI Linux runner caught them first. Signed-off-by: Bryan Frimin --- pkg/deviceagent/checks/checks_linux.go | 12 ++++++------ pkg/deviceagent/checks/checks_windows.go | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/deviceagent/checks/checks_linux.go b/pkg/deviceagent/checks/checks_linux.go index ca88af83e..479e69ab0 100644 --- a/pkg/deviceagent/checks/checks_linux.go +++ b/pkg/deviceagent/checks/checks_linux.go @@ -50,8 +50,8 @@ func linuxDiskEncryption(ctx context.Context) Result { lsblk := RunCommand(ctx, "lsblk", "-o", "NAME,TYPE,FSTYPE,MOUNTPOINT", "-r") if lsblk.Err == nil { ev["lsblk"] = truncate(lsblk.Stdout, 800) - lines := strings.Split(lsblk.Stdout, "\n") - for _, line := range lines { + lines := strings.SplitSeq(lsblk.Stdout, "\n") + for line := range lines { fields := strings.Fields(line) if len(fields) < 2 { continue @@ -168,7 +168,7 @@ func parseIptablesInput(s string) (string, int) { rules int ) - for _, line := range strings.Split(s, "\n") { + for line := range strings.SplitSeq(s, "\n") { line = strings.TrimSpace(line) switch { case strings.HasPrefix(line, "-P INPUT"): @@ -359,7 +359,7 @@ func linuxMalwareProtection(ctx context.Context) Result { func nonCommentLines(s string) []string { out := []string{} - for _, line := range strings.Split(s, "\n") { + for line := range strings.SplitSeq(s, "\n") { t := strings.TrimSpace(line) if t == "" || strings.HasPrefix(t, "#") { continue @@ -370,7 +370,7 @@ func nonCommentLines(s string) []string { } func kvLookup(body, key string) string { - for _, line := range strings.Split(body, "\n") { + for line := range strings.SplitSeq(body, "\n") { eq := strings.IndexByte(line, '=') if eq <= 0 { continue @@ -385,7 +385,7 @@ func kvLookup(body, key string) string { } func loginDefsLookup(body, key string) string { - for _, line := range strings.Split(body, "\n") { + for line := range strings.SplitSeq(body, "\n") { line = strings.TrimSpace(line) if line == "" || strings.HasPrefix(line, "#") { continue diff --git a/pkg/deviceagent/checks/checks_windows.go b/pkg/deviceagent/checks/checks_windows.go index 3c9531d86..9d4faa848 100644 --- a/pkg/deviceagent/checks/checks_windows.go +++ b/pkg/deviceagent/checks/checks_windows.go @@ -126,7 +126,7 @@ func windowsScreenLock(ctx context.Context) Result { func parseWindowsUserScreenLock(s string) (map[string]string, bool, bool) { users := map[string]string{} var anyEnabled, anyDisabled bool - for _, line := range strings.Split(s, "\n") { + for line := range strings.SplitSeq(s, "\n") { line = strings.TrimSpace(line) if line == "" { continue @@ -205,7 +205,7 @@ func parseWindowsFirewallProfiles(s string) (map[string]string, bool) { profiles := map[string]string{} allEnabled := true any := false - for _, profile := range strings.Split(s, ";") { + for profile := range strings.SplitSeq(s, ";") { parts := strings.SplitN(strings.TrimSpace(profile), "=", 2) if len(parts) != 2 { continue @@ -230,7 +230,7 @@ func parseWindowsFirewallProfiles(s string) (map[string]string, bool) { func parseNetshFirewallStates(s string) ([]string, bool) { var states []string anyOff := false - for _, line := range strings.Split(s, "\n") { + for line := range strings.SplitSeq(s, "\n") { trimmed := strings.TrimSpace(line) lower := strings.ToLower(trimmed) if !strings.HasPrefix(lower, "state") {