Go ToUpper()
Published Sep 27, 2023
Contribute to Docs
The ToUpper() function is used to convert lowercase characters to uppercase in a given string.
Syntax
result = strings.ToUpper(str)
The function accepts the given string, str, as its argument and returns the final string, result, converting lowercase characters to uppercase.
Note: This function only works with the standard characters of the alphabet.
Example
In the example below, "Codecademy" is converted to all uppercase.
package mainimport ("fmt""strings")func main() {var input string = "Codecademy"var output string = strings.ToUpper(input)fmt.Println(output)}
This example results in the following output:
CODECADEMY
Codebyte Example
In the code below, a sentence in both lowercase and uppercase is converted into just uppercase using the ToUpper() function.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Go on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use Go (Golang), an open-source programming language supported by Google!
- Beginner Friendly.6 hours