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) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| b | []byte | Byte sequence or second comparison input. |
| subslice | []byte | Byte 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é")))}