How to convert a string in lower case in Golang?

In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.
In Go string, you are allowed to convert a string in the lowercase using ToLower() function. This function returns a copy of the given string in which all the Unicode letters mapped into lower case. This function is defined under strings package, so you have to import strings package in your program to access this function.


func ToLower(str string) string

Here, str represents a string which you want to convert to lowercase.






// Go program to illustrate how to convert
// the given string to lowercase
package main
import (
// Main method
func main() {
    // Creating and initializing string
    // Using shorthand declaration
    str1 := "WelcomE, GeeksforGeeks**"
    str2 := "$$This is the, tuTorial oF Golang##"
    str3 := "HELLO! GOLANG"
    str4 := "lowercase conversion"
    // Displaying strings
    fmt.Println("Strings (before):")
    fmt.Println("String 1: ", str1)
    fmt.Println("String 2:", str2)
    fmt.Println("String 3:", str3)
    fmt.Println("String 4:", str4)
    // Converting all the string into lowercase
    // Using ToLower() function
    res1 := strings.ToLower(str1)
    res2 := strings.ToLower(str2)
    res3 := strings.ToLower(str3)
    res4 := strings.ToLower(str4)
    // Displaying the results
    fmt.Println("\nStrings (after):")
    fmt.Println("Result 1: ", res1)
    fmt.Println("Result 2:", res2)
    fmt.Println("Result 3:", res3)
    fmt.Println("Result 4:", res4)



Strings (before):
String 1:  WelcomE, GeeksforGeeks**
String 2: $$This is the, tuTorial oF Golang##
String 4: lowercase conversion

Strings (after):
Result 1:  welcome, geeksforgeeks**
Result 2: $$this is the, tutorial of golang##
Result 3: hello! golang
Result 4: lowercase conversion

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.