Quick actions

cmd+k|ctrl+k

Navigation

Languages

Strings / Find string in another string / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T09:38:50Z

Updated

2019-03-26T09:38:50Z

package main

import (
	"fmt"
	"strings"
)

func main() {
	s := "hello and second hello"
	toFind := "hello"
	idx := strings.LastIndex(s, toFind)
	fmt.Printf("when searching from end, '%s' is in s at position %d\n", toFind, idx)
}
INFO