GO语言"strings"包中"TrimSuffix"函数的用法及代码示例。
用法:
func TrimSuffix(s, suffix string) string
TrimSuffix 返回没有提供的尾随后缀字符串的 s。如果 s 不以 suffix 结尾,则 s 原样返回。
例子:
package main
import (
"fmt"
"strings"
)
func main() {
var s = "¡¡¡Hello, Gophers!!!"
s = strings.TrimSuffix(s, ", Gophers!!!")
s = strings.TrimSuffix(s, ", Marmots!!!")
fmt.Print(s)
}
输出:
¡¡¡Hello
相关用法
- GO TrimSuffix用法及代码示例
- GO TrimSpace用法及代码示例
- GO TrimRight用法及代码示例
- GO TrimLeft用法及代码示例
- GO TrimFunc用法及代码示例
- GO Trim用法及代码示例
- GO TrimRightFunc用法及代码示例
- GO TrimPrefix用法及代码示例
- GO TrimLeftFunc用法及代码示例
- GO TrailingZeros8用法及代码示例
- GO Trunc用法及代码示例
- GO TrailingZeros32用法及代码示例
- GO TrailingZeros64用法及代码示例
- GO TrailingZeros16用法及代码示例
- GO Time.Sub用法及代码示例
- GO Tx.ExecContext用法及代码示例
- GO Template用法及代码示例
- GO Time.Equal用法及代码示例
- GO ToTitle用法及代码示例
- GO Time.After用法及代码示例
注:本文由纯净天空筛选整理自golang.google.cn大神的英文原创作品 TrimSuffix。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。