Function
strings.ContainsRune
func ContainsRune(s string, r rune) bool
ContainsRune reports whether the Unicode code point r is within s.
ContainsRune报告Unicode代码点r是否在s内。
strings.join
Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.
Join将其第一个参数中的元素连接起来,创建一个单一的字符串。分隔符sep被放在结果字符串的元素之间。
strings.count
Count计算s中substr的非重叠实例的数量
strings.index
Index返回s中substr的第一个实例的索引,如果s中不存在substr,则返回-1。
strings.Fields
fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz "))
输出: Fields are: ["foo" "bar" "baz"]
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space.
Fields将字符串s围绕一个或多个连续的空白字符的实例进行分割,正如unicode.IsSpace所定义的那样,返回s的子字符串的片断,如果s只包含空白,则返回一个空片断。
strings.Contains
func Contains(s, substr string) bool
Contains reports whether substr is within s.
包含报告substr是否在s内。
strings.TrimPrefix
func TrimPrefix(s, prefix string) string
TrimPrefix returns s without the provided leading prefix string. If s doesn\\’t start with prefix, s is returned unchanged.
TrimPrefix返回没有提供前缀字符串的s。如果s不以前缀开始,s将被原样返回。
strings.HasPrefix
func HasPrefix(s, prefix string) bool
HasPrefix tests whether the string s begins with prefix.
HasPrefix测试字符串s是否以前缀开始。
func TrimSuffix
func TrimSuffix(s, suffix string) string
TrimSuffix returns s without the provided trailing suffix string. If s doesn’t end with suffix, s is returned unchanged.
TrimSuffix返回s,不包括提供的后缀字符串。如果s不以后缀结尾,s将被原样返回。
type Reader
func NewReader
func NewReader(s string) *Reader
NewReader returns a new Reader reading from s. It is similar to bytes.NewBufferString but more efficient and read-only.
它与bytes.NewBufferString相似,但效率更高,而且是只读的,它返回一个从s读取的新的阅读器。