go Repeat()方法
Repeat()语法
func Repeat(s string, count int) string
go源码中对Repeat()方法的介绍:
Repeat returns a new string consisting of count copies of the string s.
It panics if count is negative or if the result of (len(s) * count) overflows.
即go strings标准库模块中的Repeat()方法,可以返回一个以count个s字符串连接起来的新的字符串。
strings.Repeat()实例代码
func main() {
var newStr string = strings.Repeat("abc", 6)
fmt.Println(newStr)
}
运行go文件,得到输出:
abcabcabcabcabcabc