The strings Package
strings has Contains, Split, Join, Replace, ToUpper, TrimSpace, HasPrefix and more.
Example
package main
import (
"fmt"
"strings"
)
func main() {
s := " Hello, Go "
t := strings.TrimSpace(s)
fmt.Println(strings.ToUpper(t), strings.Contains(t, "Go"), strings.Split("a,b,c", ","))
fmt.Println(strings.Join([]string{"x", "y"}, "-"), strings.Replace("aaa", "a", "b", 2))
}Result
HELLO, GO true [a b c] x-y bba
Exercise
Join parts.
strings.(parts, "-")
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.