package main import ( "fmt" "strings" ) func main() { s := "hello world" fmt.Println(strings.Index(s, "world")) // -1 when the substring is absent fmt.Println(strings.Index(s, "xyz")) }
byte offset of a substring, or -1