Go ToLower()
Published Sep 5, 2023
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.
Learn Go on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use Go (Golang), an open-source programming language supported by Google!
- Beginner Friendly.6 hours