Welcome To Golang By Example

Menu
  • Home
  • Blog
Menu

Convert string to lowercase in Go (Golang)

Posted on March 11, 2023March 11, 2023 by admin

Table of Contents

  • Overview
  • Code:

Overview

In GO string are UTF-8 encoded. strings package of GO provides a ToLower method that can be used to convert all Unicode letters to their lower case. This method will return the copy of the string as in GO string are immutable.

Below is the signature of the function

func ToLower(s string) string

Let’s look at the working code

Code:

package main
import (
"fmt"
"strings"
)
func main() {
res := strings.ToLower("ABC")
fmt.Println(res)
res = strings.ToLower("ABC12$a")
fmt.Println(res)
}

Output:

abc
abc12$a

Popular Articles

Golang Comprehensive Tutorial Series

All Design Patterns in Go (Golang)

Slice in golang

Variables in Go (Golang) – Complete Guide

OOP: Inheritance in GOLANG complete guide

Using Context Package in GO (Golang) – Complete Guide

All data types in Golang with examples

Understanding time and date in Go (Golang) – Complete Guide

©2023 Welcome To Golang By Example | Design: Web XP