mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
libct: use strings.CutPrefix where possible
Using strings.CutPrefix (available since Go 1.20) instead of strings.HasPrefix and/or strings.TrimPrefix makes the code a tad more straightforward. No functional change. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -88,8 +88,8 @@ func stripRoot(root, path string) string {
|
||||
func SearchLabels(labels []string, key string) (string, bool) {
|
||||
key += "="
|
||||
for _, s := range labels {
|
||||
if strings.HasPrefix(s, key) {
|
||||
return s[len(key):], true
|
||||
if val, ok := strings.CutPrefix(s, key); ok {
|
||||
return val, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
|
||||
Reference in New Issue
Block a user