ADVERTISEMENT
ADVERTISEMENT

Golang strings.ToUpper() Function with Examples

Golang | strings.ToUpper() Function: Here, we are going to learn about the ToUpper() function of strings package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 23, 2021

strings.ToUpper()

The ToUpper() function is an inbuilt function of strings package which is used to get a copy of the string with all Unicode letters mapped to their upper case. It accepts a string and returns the string with all Unicode letters mapped to their upper case.

Syntax:

func ToUpper(str string) string

Parameter(s):

  • str : The string to be used to get the uppercase.

Return Value:

The return type of ToUpper() function is a string, it returns a copy of the string with all Unicode letters mapped to their upper case.

Example 1:

// Golang program to demonstrate the
// example of strings.ToUpper() Function

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.ToUpper("always deliver more than expected."))
	fmt.Println(strings.ToUpper("Nothing will work unless you do."))
	fmt.Println(strings.ToUpper("It's not about ideas. ..."))
	fmt.Println(strings.ToUpper("what would you do if you were not afraid?"))
}

Output:

ALWAYS DELIVER MORE THAN EXPECTED.
NOTHING WILL WORK UNLESS YOU DO.
IT'S NOT ABOUT IDEAS. ...
WHAT WOULD YOU DO IF YOU WERE NOT AFRAID?

Example 2:

// Golang program to demonstrate the
// example of strings.ToUpper() Function

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.ToUpper("abc123, 123abc, abc123xyz"))
	fmt.Println(strings.ToUpper("ABC123, 123ABC, ABC123XYZ"))
	fmt.Println(strings.ToUpper("[email protected]! [email protected]! [email protected]"))
}

Output:

ABC123, 123ABC, ABC123XYZ
ABC123, 123ABC, ABC123XYZ
[email protected]! [email protected]! [email protected]

Golang strings Package Functions »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.