How to use strings package

Use the built-in strings package to search, split, and transform text efficiently in Go.

Use the strings package to perform common string operations like searching, splitting, and replacing without importing external libraries. Import the package and call its functions directly on your string data.

package main

import (
	"fmt"
	"strings"
)

func main() {
	text := "Hello, World!"
	fmt.Println(strings.Contains(text, "World")) // true
	fmt.Println(strings.ToUpper(text))           // HELLO, WORLD!
	fmt.Println(strings.Split(text, ","))        // [Hello  World!]
}