init code
This commit is contained in:
11
internal/utils/stringx/replace.go
Normal file
11
internal/utils/stringx/replace.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package stringx
|
||||
|
||||
import "strings"
|
||||
|
||||
func ReplaceSuffix(s string, suffix string, newSuffix string) (string, bool) {
|
||||
if strings.HasSuffix(s, suffix) {
|
||||
replaced := s[:len(s)-len(suffix)] + newSuffix
|
||||
return replaced, true
|
||||
}
|
||||
return s, false
|
||||
}
|
||||
Reference in New Issue
Block a user