From ae0d41a08209faa9032ddf9bc1ff0a4d1f8cfa77 Mon Sep 17 00:00:00 2001 From: Bruno De Assis Marques Date: Sat, 21 Feb 2026 06:10:34 +1100 Subject: [PATCH] refactor: use text cases to convert to title case Signed-off-by: Bruno De Assis Marques --- pkg/hardware/node_spec.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/pkg/hardware/node_spec.go b/pkg/hardware/node_spec.go index 4146b7fb..77f49c39 100644 --- a/pkg/hardware/node_spec.go +++ b/pkg/hardware/node_spec.go @@ -2,7 +2,12 @@ package hardware -import "fmt" +import ( + "fmt" + + "golang.org/x/text/cases" + "golang.org/x/text/language" +) // nodeSpec implements Spec by combining requirements from the registry // with the actual host profile for validation. @@ -36,19 +41,8 @@ func NewNodeSpec(nodeType, profile string, hostProfile HostProfile) (Spec, error // formatDisplayName creates a human-readable display name func formatDisplayName(nodeType, profile string) string { - return fmt.Sprintf("%s Node (%s)", capitalize(nodeType), capitalize(profile)) -} - -// capitalize capitalizes the first letter of a string -func capitalize(s string) string { - if len(s) == 0 { - return s - } - // Simple ASCII uppercase for first char - if s[0] >= 'a' && s[0] <= 'z' { - return string(s[0]-('a'-'A')) + s[1:] - } - return s + caser := cases.Title(language.Und) + return fmt.Sprintf("%s Node (%s)", caser.String(nodeType), caser.String(profile)) } // GetProfile returns the deployment profile