how to convert string to lowercase in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

To convert string to lowercase in golang, just use ToLower() method and pass your string, it will convert string into lowercase.


Follow the below tutorial if you are struggling with installing GO in windows.

https://aguidehub.com/blog/how-to-install-golang-in-windows


Today, I will show you how do I convert string to lowercase in golang, as above mentioned I’m going to use ToLower() way.

The strings package provide ToLower() method.

Let’s start our Golang convert string to lowercase example

Convert whole string into lowercase example

main.go

package main

import (
    "fmt"
    "strings"
)

func main() {

  str1 := "aGuideHub"
  str2 := "Infinitbility"
  str3 := "sortoutcode"

  res1 := strings.ToLower(str1)
  res2 := strings.ToLower(str2)
  res3 := strings.ToLower(str3)

  fmt.Println("Result 1:", res1)
  fmt.Println("Result 2:", res2)
  fmt.Println("Result 3:", res3)
}

In the above example, we have converted string to lowercase and printed in golang console. let’s check the output.

Output

Result 1: aguidehub
Result 2: infinitbility
Result 3: sortoutcode

Try it Yourself

I hope it helps you, All the best 👍.