How to check whether a string s ends with specific substring in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.HasSuffix("golang", "lang"))
	fmt.Println(strings.HasSuffix("java", "a"))
	fmt.Println(strings.HasSuffix("python", "py"))
	fmt.Println(strings.HasSuffix("php", ""))
}



/*
run:

true
true
false
true

*/

 



answered Aug 20, 2020 by avibootz
...