From 619b419a4b1506bde1aa7e833898f2f67fd0e83e Mon Sep 17 00:00:00 2001 From: apocelipes Date: Sat, 4 May 2024 10:17:30 +0000 Subject: os: use stringslite.TrimSuffix Change-Id: Ie51a1550181c9478455c757fc82a88bc549ad687 GitHub-Last-Rev: 4b6ffd043b0f2acebb8d2477da17a4d1dfe708ed GitHub-Pull-Request: golang/go#67153 Reviewed-on: https://go-review.googlesource.com/c/go/+/583095 Auto-Submit: Ian Lance Taylor Commit-Queue: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Ian Lance Taylor --- src/os/executable_procfs.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/os/executable_procfs.go b/src/os/executable_procfs.go index 94e674e364..6a2cd10be7 100644 --- a/src/os/executable_procfs.go +++ b/src/os/executable_procfs.go @@ -8,6 +8,7 @@ package os import ( "errors" + "internal/stringslite" "runtime" ) @@ -25,13 +26,5 @@ func executable() (string, error) { // When the executable has been deleted then Readlink returns a // path appended with " (deleted)". - return stringsTrimSuffix(path, " (deleted)"), err -} - -// stringsTrimSuffix is the same as strings.TrimSuffix. -func stringsTrimSuffix(s, suffix string) string { - if len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix { - return s[:len(s)-len(suffix)] - } - return s + return stringslite.TrimSuffix(path, " (deleted)"), err } -- cgit v1.2.3-54-g00ecf