How to get the index of the first instance of substring in a string with Go

1 Answer

0 votes
package main

import (
	"fmt"
	"strings"
)

func main() {
    fmt.Println(strings.Index("java php go c go", "go"))
	fmt.Println(strings.Index("java php go c go", "c++"))
}



/*
run:

9
-1

*/

 



answered Aug 20, 2020 by avibootz

Related questions

1 answer 1,090 views
1 answer 157 views
2 answers 196 views
1 answer 161 views
...