ToUpper()
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.
Looking to contribute?
- 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.