Standard library / bytes
bytes.Count()
Counts non-overlapping occurrences. An empty separator counts decoded runes plus one. Expected stdout: '2\n'.
Formal Syntax & Structure
go syntaxgo
func Count(s, sep []byte) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | []byte | Input text or sequence. |
| sep | []byte | Separator or search sequence. |
Return Value
int
Counts non-overlapping occurrences. An empty separator counts decoded runes plus one.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { fmt.Println(bytes.Count([]byte("aaaa"), []byte("aa")))}