From 39f59c32892a0461636b200a720f710cd2b2d9f4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 31 Oct 2022 19:09:36 +0100 Subject: [PATCH] daemon/links: use strings.Cut() Signed-off-by: Sebastiaan van Stijn --- daemon/links/links.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/links/links.go b/daemon/links/links.go index a51c97d1f0..ba4381a565 100644 --- a/daemon/links/links.go +++ b/daemon/links/links.go @@ -94,15 +94,15 @@ func (l *Link) ToEnv() []string { if l.ChildEnvironment != nil { for _, v := range l.ChildEnvironment { - parts := strings.SplitN(v, "=", 2) - if len(parts) < 2 { + name, val, ok := strings.Cut(v, "=") + if !ok { continue } // Ignore a few variables that are added during docker build (and not really relevant to linked containers) - if parts[0] == "HOME" || parts[0] == "PATH" { + if name == "HOME" || name == "PATH" { continue } - env = append(env, fmt.Sprintf("%s_ENV_%s=%s", alias, parts[0], parts[1])) + env = append(env, fmt.Sprintf("%s_ENV_%s=%s", alias, name, val)) } } return env