ToLower()
Published Sep 5, 2023
Contribute to Docs
The strings.ToLower()
function is a built-in function in Golang that returns a new string with all the characters in the original string converted to lowercase. The original string is not modified.
Syntax
strings.ToLower(str)
Where str
is the string to convert into lowercase.
Example
The following example demonstrates the use of the strings.ToLower()
function.
package mainimport ("fmt""strings")func main() {str := "Hello World!"lowerStr := strings.ToLower(str)fmt.Println("The original string is:", str)fmt.Println("The lowercase version of the string is:", lowerStr)}
The output will be:
The original string is: Hello World!The lowercase version of the string is: hello world!
Codebyte Example
The following example is runnable and uses the strings.ToLower()
function to convert three strings into lowercase.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.