GopherSnippetsStar

Code snippets with tests and testable examples for the Go programming language

How to check if a string ends with a substring

Snippets Index - Run code on Go playground - Edit

package main

import (
	"fmt"
	"strings"
)

func Example() {
	fmt.Println(strings.HasSuffix("abcdefg", "fg"))
	fmt.Println(strings.HasSuffix("abcdefg", "Fg"))
	// Output:
	// true
	// false
}

by psampaz - source code - comment below or here