Menu Close

Go – How to convert strings into lower case in go

Here, We will learn how to convert strings into lower case in go. We can do it by using ToLower() function in strings package in go golang.

Function prototype:

func ToLower(str string) string

Return value:

ToLower() function in strings package returns 
strings with all Unicode letters mapped to
their lower case.

Example with code:

package main

import (
  "fmt"
  "strings"
)

func main() {

  s := strings.ToLower("Go GoLang")
  fmt.Println(s)

  s = strings.ToLower("go golang")
  fmt.Println(s)

  s = strings.ToLower("Go GoLang 123 #")
  fmt.Println(s)

  s = strings.ToLower("0 9 # Go GoLang ")
  fmt.Println(s)
}

Output:

go golang
go golang
go golang 123#
0 9 # go golang

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, strings

Leave a Reply

Your email address will not be published. Required fields are marked *