strings
func Contains(s, substr string) bool
:是否包含字串
func ContainsAny(s, chars string) bool
func ContainsRune(s string, r rune) bool
func Count(s, substr string) int
func EqualFold(s, t string) bool
: 不区分大小写,eg "GO", "go"
func Fields(s string) []string
: 按空格将字符串转化为slice
func HasPrefix(s, prefix string) bool
:是否有前缀
func HasSuffix(s, suffix string) bool
:是否有后缀
func Index(s, substr string) int
:返回字串第一次出现的索引,没有返回-1
func IndexRune(s string, r rune) int
:返回rune一次出现的索引,没有返回-1
func Join(a []string, sep string) string
:将slice转化为字符串
func LastIndex(s, substr string) int
:返回字串最后一次出现的索引,没有返回-1
func Map(mapping func(rune) rune, s string) string
: map each rune
func Repeat(s string, count int) string
: repeat count 次
func Replace(s, old, new string, n int) string
:替换
func ReplaceAll(s, old, new string) string
:替换所有
func Split(s, sep string) []string
:将字符串转化为数组/slice
func ToLower(s string) string
:小写
func ToUpper(s string) string
:大写
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.
func (r *Reader) Len() int
:Len returns the number of bytes of the unread portion of the string.
func (r *Reader) Read(b []byte) (n int, err error)
func (r *Reader) ReadByte() (byte, error)
func (r *Reader) ReadRune() (ch rune, size int, err error)
func (r *Reader) WriteTo(w io.Writer) (n int64, err error)
:WriteTo implements the io.WriterTo interface.