Skip to content

Commit 3a0b5e8

Browse files
committed
libcontainer: replace deprecated strings.Title with manual capitalization
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]>
1 parent bc432ce commit 3a0b5e8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libcontainer/criu_linux.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ func (c *Container) criuSupportsExtNS(t configs.NamespaceType) bool {
183183
}
184184

185185
func criuNsToKey(t configs.NamespaceType) string {
186-
return "extRoot" + strings.Title(configs.NsName(t)) + "NS" //nolint:staticcheck // SA1019: strings.Title is deprecated
186+
// Construct "extRoot" + capitalize(nsName) + "NS" without allocations.
187+
// Result format: "extRootNetNS", "extRootPidNS", etc.
188+
nsName := configs.NsName(t)
189+
out := make([]byte, 0, 64)
190+
out = append(out, "extRoot"...)
191+
// Capitalize the first character (this assumes it's in the a-z range).
192+
out = append(out, nsName[0]-'a'+'A')
193+
out = append(out, nsName[1:]...)
194+
out = append(out, "NS"...)
195+
196+
return string(out)
187197
}
188198

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

0 commit comments

Comments
 (0)