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) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| b | []byte | Byte sequence or second comparison input. |
| count | int | Number 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)))}