Go 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.

  • 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

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

All contributors

Contribute to Docs

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