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) string

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
countintNumber 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)))}
Go Reference