From 139c2c4f9af88730db91bad0ec86fbacda936e44 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Fri, 31 Oct 2025 12:20:58 +0000 Subject: [PATCH] refactor: replace backport with `strings.CutSuffix` The `cutSuffix` function was added to backport the functionality of `strings.CutSuffix` from Go 1.20. Now that we're using Go 1.25, we can safely replace our backport with the standard library function. Our backport was an intact copy/paste of the stdlib implementation, so this change does not alter any behavior. Signed-off-by: Babak K. Shandiz --- internal/ghinstance/host.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/internal/ghinstance/host.go b/internal/ghinstance/host.go index be839d62e..7abfd83ac 100644 --- a/internal/ghinstance/host.go +++ b/internal/ghinstance/host.go @@ -26,7 +26,7 @@ func Default() string { // reports whether it found the tenant name. func TenantName(h string) (string, bool) { normalizedHostName := ghauth.NormalizeHostname(h) - return cutSuffix(normalizedHostName, "."+tenancyHost) + return strings.CutSuffix(normalizedHostName, "."+tenancyHost) } func isGarage(h string) bool { @@ -96,11 +96,3 @@ func HostPrefix(hostname string) string { } return fmt.Sprintf("https://%s/", hostname) } - -// Backport strings.CutSuffix from Go 1.20. -func cutSuffix(s, suffix string) (string, bool) { - if !strings.HasSuffix(s, suffix) { - return s, false - } - return s[:len(s)-len(suffix)], true -}