To convert a string to lowercase in Go, you can use the strings.ToLower
function.
In this example,
str
with the value "Hello World"
.strings.ToLower
with str
as argument and store the result in a new variable lowercaseStr
.lowercaseStr
.package main
import (
"fmt"
"strings"
)
func main() {
str := "Hello World"
lowercaseStr := strings.ToLower(str)
fmt.Println(lowercaseStr)
}
hello world
In this example,
str
with the value "Go Programming"
.strings.ToLower
with str
as argument and store the result in a new variable lowercaseStr
.lowercaseStr
.package main
import (
"fmt"
"strings"
)
func main() {
str := "Go Programming"
lowercaseStr := strings.ToLower(str)
fmt.Println(lowercaseStr)
}
go programming
In this tutorial, we learned How to convert String to Lowercase in Go language with well detailed examples.