ToUpper()

Jayburley's avatar
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 main
import (
"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.

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Go on Codecademy