Skip to content

Instantly share code, notes, and snippets.

@wesinator
Created December 31, 2019 05:54
Show Gist options
  • Save wesinator/27221e5f6b6f96205afca5673bf4ee48 to your computer and use it in GitHub Desktop.
Save wesinator/27221e5f6b6f96205afca5673bf4ee48 to your computer and use it in GitHub Desktop.
import "strings"
// return index of second to last occurrence of char in string
func SecondToLast(str string, char string) int {
return strings.LastIndex(str[0:strings.LastIndex(str, char)], char)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment