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-26T10:12:31Z

Updated

2019-03-26T10:12:31Z

package main

import (
	"fmt"
	"strings"
)

func main() {
	s := "this is string"
	toFind := "string"
	if strings.HasSuffix(s, toFind) {
		fmt.Printf("'%s' ends with '%s'\n", s, toFind)
	} else {
		fmt.Printf("'%s' doesn't end with '%s'\n", s, toFind)
	}
}
INFO