TrimSuffix

TrimSuffix 返回字符串 s 去除后缀suffix的字符串。

TrimSuffix

函数定义

func TrimSuffix(s, suffix string) string

代码示例

package main

import (
    "fmt"
    "strings"
)

func main() {
    var s = "@@@Hello, Gophers!!!"
    s = strings.TrimSuffix(s, ", Gophers!!!")
    s = strings.TrimSuffix(s, ", Marmots!!!")
    fmt.Print(s)
}

// Output:
// @@@Hello