Wednesday, February 21, 2024
HomeSoftware EngineeringHow you can UpperCase a String in Golang

How you can UpperCase a String in Golang


In Go, there are a number of methods to make a string UpperCase, every of them are by utilizing the strings bundle.

Possibility 1 (strings.ToUpper):

func ToUpper(str string) string

bundle principal

import (
    "fmt"
    "strings"
)

func principal() {
    str1 := "This can be a Check"
    fmt.Println(strings.ToUpper(str1))

    // "THIS IS A TEST"
}

Possibility 2 (strings.ToTitle):

func ToTitle(str string) string

bundle principal

import (
    "fmt"
    "strings"
)

func principal() {
    str1 := "This can be a Check"
    fmt.Println(strings.ToTitle(str1))

    // "THIS IS A TEST"
}
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments