How to UpperCase a String in Golang

0 min read 80 words

In Go, there are multiple ways to make a string UpperCase, each of them are by using the strings package.

Option 1 (strings.ToUpper):

func ToUpper(str string) string

package main

import (
    "fmt"
    "strings"
)

func main() {
    str1 := "This is a Test"
    fmt.Println(strings.ToUpper(str1))

    // "THIS IS A TEST"
}

Option 2 (strings.ToTitle):

func ToTitle(str string) string

package main

import (
    "fmt"
    "strings"
)

func main() {
    str1 := "This is a Test"
    fmt.Println(strings.ToTitle(str1))

    // "THIS IS A TEST"
}
Tags:
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags

Recent Posts