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

1 Answer

0 votes
package main
 
import (
    "fmt"
    "strings"
)
 
func main() {
    fmt.Println(strings.LastIndexByte("go php", 'p'))
    fmt.Println(strings.LastIndexByte("go php go", 'g'))
    fmt.Println(strings.LastIndexByte("go php", 'e'))
}
 
 
 
/*
run:
  
5
7
-1
  
*/

 



answered Aug 20, 2020 by avibootz
...