Standard library / bytes

bytes.Contains()

Reports whether the literal sequence occurs anywhere, including an empty search sequence. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Contains(b, subslice []byte) bool

Parameters & Attributes

NameTypeDescription
b[]byteByte sequence or second comparison input.
subslice[]byteByte subsequence to search for.

Return Value

bool

Reports whether the literal sequence occurs anywhere, including an empty search sequence.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(bytes.Contains([]byte("café"), []byte("fé")))}
Go Reference