Welcome To Golang By Example

Menu
  • Home
  • Blog
  • Contact Us
  • Support this website
Menu

Convert string to uppercase in Go (Golang)

Posted on March 11, 2020March 11, 2020 by admin

Table of Contents

  • Overview
  • Code:

Overview

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

Below is the signature of the function

Let’s look at the working code

Code:

package main

import (
    "fmt"
    "strings"
)

func main() {
    res := strings.ToUpper("abc")
    fmt.Println(res)

    res = strings.ToUpper("abc12$")
    fmt.Println(res)
}

Output:

ABC
ABC12$
Follow @golangbyexample

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

©2025 Welcome To Golang By Example | Design: Newspaperly WordPress Theme