From 1adb070b58713c973534ecee6715384583ee008f Mon Sep 17 00:00:00 2001 From: Osama Abdelkader Date: Mon, 6 Oct 2025 15:20:33 +0300 Subject: [PATCH] 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 Co-authored-by: Kir Kolyshkin --- libcontainer/criu_linux.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libcontainer/criu_linux.go b/libcontainer/criu_linux.go index a86e53fd785..fb435e11112 100644 --- a/libcontainer/criu_linux.go +++ b/libcontainer/criu_linux.go @@ -15,6 +15,7 @@ import ( "reflect" "strings" "time" + "unicode" "github.com/checkpoint-restore/go-criu/v7" criurpc "github.com/checkpoint-restore/go-criu/v7/rpc" @@ -183,7 +184,19 @@ func (c *Container) criuSupportsExtNS(t configs.NamespaceType) bool { } func criuNsToKey(t configs.NamespaceType) string { - return "extRoot" + strings.Title(configs.NsName(t)) + "NS" //nolint:staticcheck // SA1019: strings.Title is deprecated + // Construct "extRoot" + capitalize(nsName) + "NS" without allocations. + // Result format: "extRootNetNS", "extRootPidNS", etc. + nsName := configs.NsName(t) + out := make([]byte, 0, 32) + out = append(out, "extRoot"...) + // Capitalize the first character (this assumes it's in the a-z range). + if len(nsName) > 0 { + out = append(out, byte(unicode.ToUpper(rune(nsName[0])))) + out = append(out, nsName[1:]...) + } + out = append(out, "NS"...) + + return string(out) } func (c *Container) handleCheckpointingExternalNamespaces(rpcOpts *criurpc.CriuOpts, t configs.NamespaceType) error {