refactor: replace Split in loops with more efficient SplitSeq and replace HasPrefix+TrimPrefix with CutPrefix
Some checks failed
ci / validate (lint) (push) Has been cancelled
ci / validate (validate-docs) (push) Has been cancelled
ci / validate (validate-go-mod) (push) Has been cancelled
ci / validate (validate-headers) (push) Has been cancelled
ci / binary (push) Has been cancelled
ci / bin-image-test (push) Has been cancelled
ci / test (push) Has been cancelled
ci / e2e (plugin, oldstable) (push) Has been cancelled
ci / e2e (standalone, oldstable) (push) Has been cancelled
ci / e2e (plugin, stable) (push) Has been cancelled
ci / e2e (standalone, stable) (push) Has been cancelled
merge / bin-image-prepare (push) Has been cancelled
merge / module-image (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
ci / binary-finalize (push) Has been cancelled
ci / coverage (push) Has been cancelled
ci / release (push) Has been cancelled
merge / bin-image (push) Has been cancelled
merge / desktop-edge-test (push) Has been cancelled

Signed-off-by: caltechustc <caltechustc@outlook.com>
This commit is contained in:
caltechustc 2026-05-23 20:09:25 +08:00 committed by Guillaume Lours
parent 9834762bd7
commit 5d67ce6dfe

View file

@ -416,10 +416,10 @@ func TestBuildPlatformsStandardErrors(t *testing.T) {
output := inspect.Stdout()
isDockerDriver := false
platforms := ""
for _, line := range strings.Split(output, "\n") {
for line := range strings.SplitSeq(output, "\n") {
trimmed := strings.TrimSpace(line)
if strings.HasPrefix(trimmed, "Driver:") {
isDockerDriver = strings.TrimSpace(strings.TrimPrefix(trimmed, "Driver:")) == "docker"
if after, ok := strings.CutPrefix(trimmed, "Driver:"); ok {
isDockerDriver = strings.TrimSpace(after) == "docker"
}
if strings.HasPrefix(trimmed, "Platforms:") {
platforms = trimmed