ToLower()

manviii_27's avatar
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 main
import (
"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.

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Go on Codecademy