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 <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-26 10:02:21 -07:00
parent 378a7d6d9c
commit e6f988834d
2 changed files with 9 additions and 9 deletions

View File

@@ -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

View File

@@ -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") {