Standard library / bytes

bytes.Repeat()

Returns count concatenated copies; negative count or length overflow panics. Expected stdout: 'ababab\n'.

Formal Syntax & Structure

go syntaxgo
func Repeat(b []byte, count int) []byte

Parameters & Attributes

NameTypeDescription
b[]byteByte sequence or second comparison input.
countintNumber of repetitions.

Return Value

[]byte

Returns count concatenated copies; negative count or length overflow panics.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(string(bytes.Repeat([]byte("ab"), 3)))}
Go Reference