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

1 Answer

0 votes
package main
 
import (
    "fmt"
    "strings"
)
 
func main() {
    fmt.Println(strings.LastIndex("java php go c go", "go"))
    fmt.Println(strings.LastIndex("java php go c go", "c++"))
}
 
 
 
/*
run:
 
14
-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
...