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

@ -97,8 +97,8 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
// Should we store the ENV we actually want in the spec separately?
if c.config.Spec.Process != nil {
for _, e := range c.config.Spec.Process.Env {
splitEnv := strings.SplitN(e, "=", 2)
importBuilder.SetEnv(splitEnv[0], splitEnv[1])
key, val, _ := strings.Cut(e, "=")
importBuilder.SetEnv(key, val)
}
}
// Expose ports