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 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.

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Go on Codecademy