From: Tobias Klauser Date: Tue, 12 Sep 2023 14:14:36 +0000 (+0200) Subject: testing: use strings.LastIndexAny in (*common).decorate X-Git-Tag: go1.22rc1~866 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=dd2279ee344a59ad50a73ebce5ab80c93fbbe732;p=gostls13.git testing: use strings.LastIndexAny in (*common).decorate Change-Id: I14c521f4e599e14c71a52342b0ead5d0d4007f1e Reviewed-on: https://go-review.googlesource.com/c/go/+/527655 Auto-Submit: Tobias Klauser Reviewed-by: Kirill Kolyshkin Reviewed-by: Bryan Mills LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor --- diff --git a/src/testing/testing.go b/src/testing/testing.go index 1bc8aff00d..d89a99454d 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -771,9 +771,7 @@ func (c *common) decorate(s string, skip int) string { if file != "" { if *fullPath { // If relative path, truncate file name at last file name separator. - } else if index := strings.LastIndex(file, "/"); index >= 0 { - file = file[index+1:] - } else if index = strings.LastIndex(file, "\\"); index >= 0 { + } else if index := strings.LastIndexAny(file, `/\`); index >= 0 { file = file[index+1:] } } else {