Skip to content

Commit 1adb070

Browse files
osamakaderkolyshkin
andcommitted
criu: replace deprecated strings.Title
strings.Title is deprecated since Go 1.18. Replace it with a simple manual capitalization of the first character in criuNsToKey(). Signed-off-by: Osama Abdelkader <[email protected]> Co-authored-by: Kir Kolyshkin <[email protected]>
1 parent bc432ce commit 1adb070

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

libcontainer/criu_linux.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"reflect"
1616
"strings"
1717
"time"
18+
"unicode"
1819

1920
"github.com/checkpoint-restore/go-criu/v7"
2021
criurpc "github.com/checkpoint-restore/go-criu/v7/rpc"
@@ -183,7 +184,19 @@ func (c *Container) criuSupportsExtNS(t configs.NamespaceType) bool {
183184
}
184185

185186
func criuNsToKey(t configs.NamespaceType) string {
186-
return "extRoot" + strings.Title(configs.NsName(t)) + "NS" //nolint:staticcheck // SA1019: strings.Title is deprecated
187+
// Construct "extRoot" + capitalize(nsName) + "NS" without allocations.
188+
// Result format: "extRootNetNS", "extRootPidNS", etc.
189+
nsName := configs.NsName(t)
190+
out := make([]byte, 0, 32)
191+
out = append(out, "extRoot"...)
192+
// Capitalize the first character (this assumes it's in the a-z range).
193+
if len(nsName) > 0 {
194+
out = append(out, byte(unicode.ToUpper(rune(nsName[0]))))
195+
out = append(out, nsName[1:]...)
196+
}
197+
out = append(out, "NS"...)
198+
199+
return string(out)
187200
}
188201

189202
func (c *Container) handleCheckpointingExternalNamespaces(rpcOpts *criurpc.CriuOpts, t configs.NamespaceType) error {

0 commit comments

Comments
 (0)