Golang Convert String to Lowercase - ToLower() - Example

Golang Convert String to Lowercase ? ToLower() ? Example

Golang ? String to Lowercase

To convert string to lowercase in Golang, you can use strings.ToLower() function. The syntax of ToLower() function is:

strings.ToLower(str)

where

1. strings is the package 2. ToLower is the keyword 3. str is the input string

strings.ToLower() function returns string with all character converted to lower case alphabets.

In this tutorial, we will learn how to transform a string to lower case in Golang.

Golang Example to Convert String to Lower Case

In this example, we will take a string containing a mix of lower and upper case alphabets and convert it to lower case.

example.go

package main import (

"fmt" "strings" ) func main() { var str = "HelLo WoRld" var str_lower = strings.ToLower(str) fmt.Printf(str_lower) }

Output

C:\workspace\go>go run example.go hello world

Conclusion

In this Golang Tutorial, we learned how to convert a string to lower case.

Golang Golang Tutorial Run Golang Program Golang If Else Golang Switch Golang For Loop Golang Comments Golang Functions Golang Array Golang Slice Golang Struct Golang Class Golang Range Golang Map Golang Goroutine Golang Channel

Golang String Operations Golang String Length Golang String Concatenation Golang Split String Golang String - Get Index of Substr Golang String to Uppercase

Golang String to Lowercase Golang Convert String to Integer

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download