From 2cef961be9f6c9c1c8febe675a3ed29b07f75e50 Mon Sep 17 00:00:00 2001 From: chressie Date: Fri, 17 Mar 2023 11:59:41 +0100 Subject: [PATCH] glog: use strings.TrimSuffix This was raised in https://github.com/golang/glog/pull/53. cl/514318873 (google-internal) --- glog_flags.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/glog_flags.go b/glog_flags.go index 3060e54d..fc486455 100644 --- a/glog_flags.go +++ b/glog_flags.go @@ -192,9 +192,7 @@ func (f *verboseFlags) levelForPC(pc uintptr) Level { file, _ := fn.FileLine(pc) // The file is something like /a/b/c/d.go. We want just the d for // regular matches, /a/b/c/d for full matches. - if strings.HasSuffix(file, ".go") { - file = file[:len(file)-3] - } + file = strings.TrimSuffix(file, ".go") full := file if slash := strings.LastIndex(file, "/"); slash >= 0 { file = file[slash+1:]