Standard library / bytes

bytes.IndexByte()

Returns the byte offset of the first matching byte, or -1; not a rune search. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func IndexByte(b []byte, c byte) int

Parameters & Attributes

NameTypeDescription
b[]byteByte sequence or second comparison input.
cbyteByte to match or special case mapping, according to type.

Return Value

int

Returns the byte offset of the first matching byte, or -1; not a rune search.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(bytes.IndexByte([]byte("égo"), 'g'))}
Go Reference