Go Strings
ExampleGo
package main
import (
"fmt"
"strings"
)
func main() {
s := "Hello, Go"
fmt.Println(len(s))
fmt.Println(strings.ToUpper(s))
fmt.Println(strings.Contains(s, "Go"))
fmt.Println(strings.Split("a,b,c", ","))
fmt.Println(strings.Replace(s, "Go", "World", 1))
fmt.Println(strings.Repeat("ab", 3))
fmt.Println(s[7:])
fmt.Println(strings.Join([]string{"x", "y", "z"}, "-"))
fmt.Printf("%s has %d items costing %.2f\n", "Cart", 3, 9.5)
}Output
9 HELLO, GO true [a b c] Hello, World ababab Go x-y-z Cart has 3 items costing 9.50
Quick check
Which package has string helpers like ToUpper?
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.