Home »
Golang »
Golang Reference
Golang strings.ToLower() Function with Examples
Golang | strings.ToLower() Function: Here, we are going to learn about the ToLower() function of the strings package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 19, 2021
strings.ToLower()
The ToLower() function is an inbuilt function of strings package which is used to get a copy of the string with all Unicode letters mapped to their lower case. It accepts a string and returns the string with all Unicode letters mapped to their lower case.
Syntax
func ToLower(str string) string
Parameters
- str : The string to be used to get the lowercase.
Return Value
The return type of ToLower() function is a string, it returns a copy of the string with all Unicode letters mapped to their lower case.
Example 1
// Golang program to demonstrate the
// example of strings.ToLower() Function
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.ToLower("always deliver more than expected."))
fmt.Println(strings.ToLower("Nothing will work unless you do."))
fmt.Println(strings.ToLower("It's not about ideas. ..."))
fmt.Println(strings.ToLower("what would you do if you were not afraid?"))
}
Output:
always deliver more than expected.
nothing will work unless you do.
it's not about ideas. ...
what would you do if you were not afraid?
Example 2
// Golang program to demonstrate the
// example of strings.ToLower() Function
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.ToLower("abc123, 123abc, abc123xyz"))
fmt.Println(strings.ToLower("ABC123, 123ABC, ABC123XYZ"))
fmt.Println(strings.ToLower("okay@123! OKAY@123! 123!@okay"))
}
Output:
abc123, 123abc, abc123xyz
abc123, 123abc, abc123xyz
okay@123! okay@123! 123!@okay
Golang strings Package Functions »