replace strings.SplitN with strings.Cut

Signed-off-by: Amir M. Ghazanfari <a.m.ghazanfari76@gmail.com>
This commit is contained in:
Amir M. Ghazanfari
2024-09-28 10:02:21 +03:30
parent 15904913c2
commit faffe1b9ee
5 changed files with 18 additions and 20 deletions
+2 -3
View File
@@ -259,11 +259,10 @@ func containerInit(t initType, config *initConfig, pipe *syncSocket, consoleSock
// current processes's environment.
func populateProcessEnvironment(env []string) error {
for _, pair := range env {
p := strings.SplitN(pair, "=", 2)
if len(p) < 2 {
name, val, ok := strings.Cut(pair, "=")
if !ok {
return errors.New("invalid environment variable: missing '='")
}
name, val := p[0], p[1]
if name == "" {
return errors.New("invalid environment variable: name cannot be empty")
}