modernize: Use strings.CutSuffix

Added in Go 1.20

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-12-15 18:32:55 +01:00
parent 71fd582aa2
commit 6c5233e109
6 changed files with 15 additions and 15 deletions

View File

@@ -420,8 +420,8 @@ func (v *localVolume) LiveRestoreVolume(ctx context.Context, _ string) error {
// getAddress finds out address/hostname from options
func getAddress(opts string) string {
for opt := range strings.SplitSeq(opts, ",") {
if strings.HasPrefix(opt, "addr=") {
return strings.TrimPrefix(opt, "addr=")
if after, ok := strings.CutPrefix(opt, "addr="); ok {
return after
}
}
return ""
@@ -430,8 +430,8 @@ func getAddress(opts string) string {
// getPassword finds out a password from options
func getPassword(opts string) string {
for opt := range strings.SplitSeq(opts, ",") {
if strings.HasPrefix(opt, "password=") {
return strings.TrimPrefix(opt, "password=")
if after, ok := strings.CutPrefix(opt, "password="); ok {
return after
}
}
return ""