Skip to content

strings: Docs & Examples unclear about difference between ToTitle and ToUpper #37334

@dionysius

Description

@dionysius

What version of Go are you using (go version)?

The current documentation on https://golang.org/pkg/strings/

Does this issue reproduce with the latest release?

Yes, using the examples inside the strings package documentation

What operating system and processor architecture are you using (go env)?

None providable

What did you do?

Copied strings.ToTitle example to strings.ToUpper and changed ToTitle() to ToUpper():

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.ToUpper("her royal highness"))
	fmt.Println(strings.ToUpper("loud noises"))
	fmt.Println(strings.ToUpper("хлеб"))
}

What did you expect to see?

A difference in output.

What did you see instead?

Example ToTitle (unmodified) outputs:

HER ROYAL HIGHNESS
LOUD NOISES
ХЛЕБ

Example ToUpper (modified as described above) outputs:

HER ROYAL HIGHNESS
LOUD NOISES
ХЛЕБ

No difference. So for me it is unclear which function is now the correct one to use for an imaginary case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions