Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

String Contains, HasPrefix, HasSuffix

  • Contains
  • HasPrefix
  • HasSuffix
package main

import (
	"fmt"
	"strings"
)

func main() {
	text := "Some text here"
	fmt.Println(text)
	fmt.Println(strings.HasSuffix(text, "here"))
	fmt.Println(strings.HasPrefix(text, "here"))
	fmt.Println(strings.HasPrefix(text, "So"))

	fmt.Println(strings.Contains(text, "text"))

}