mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
refactor: replace Split in loops with more efficient SplitSeq and replace HasPrefix+TrimPrefix with CutPrefix
Signed-off-by: caltechustc <[email protected]>
This commit is contained in:
committed by
Guillaume Lours
parent
9834762bd7
commit
5d67ce6dfe
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user