How to convert string to lowercase in Golang

  • 07 May 2019
  • ADM


How to convert string to lowercase in Golang - images/logos/golang.jpg


Here is a simple snippet of how to convert a string to lowercase using Golang. If you need help how to install Golang check the references links.


To convert a string into lowercase, use the ToLower method from strings package.

package main

import (	

func main() {
	str := "Hello from"
	res:= strings.ToLower(str)
	fmt.Println("String to Lowercase Golang example")
	fmt.Println(str + " ==> " + res)


To compile the code navigate to the file location and run the following command.

$ go build stringToLower.go

Then depending on if you are on Linux or Windows the binary file is created.

To run the application execute the command.


$ ./stringToLower


c:\Users\adm\go\tutorials> stringToLower.exe

If you want to compile and run the application in one single step run the following command:

go run stringToLower.go


Will display the following output.

String to Lowercase Golang example

Hello from ==> hello from