Replace strings.SplitN with strings.Cut

Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
This commit is contained in:
Philip Dubé
2024-01-02 18:31:25 +00:00
parent f1ea4fbb3d
commit 522934d5cf
56 changed files with 596 additions and 678 deletions

View File

@ -40,9 +40,9 @@ func parseUserInput(input string) (container string, path string) {
return
}
if spl := strings.SplitN(path, ":", 2); len(spl) == 2 {
container = spl[0]
path = spl[1]
if parsedContainer, parsedPath, ok := strings.Cut(path, ":"); ok {
container = parsedContainer
path = parsedPath
}
return
}