You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
473 B
Go

package cmd
import (
"github.com/spf13/cobra"
"unicode/utf8"
)
func init() {
rootCmd.AddCommand(testCmd)
}
var testCmd = &cobra.Command{
Use: "test",
Short: "Only for test",
Run: func(cmd *cobra.Command, args []string) {
},
}
func removeLastChar1(s string) string {
if len(s) == 0 {
return s
}
// 获取最后一个字符的长度
_, size := utf8.DecodeLastRuneInString(s)
// 使用 strings 包中的函数来处理字符串
return s[:len(s)-size]
}