Standard library / strings
strings.Repeat()
Returns count concatenated copies; negative count or length overflow panics. Expected stdout: 'ababab\n'.
Formal Syntax & Structure
go syntaxgo
func Repeat(s string, count int) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| count | int | Number of repetitions. |
Return Value
string
Returns count concatenated copies; negative count or length overflow panics.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { fmt.Println(string(strings.Repeat("ab", 3)))}