Skip to content

staticcheck: flag strings.ToUpper(name[:1])+name[1:] #517

@dominikh

Description

@dominikh

String slicing works based on bytes, not runes. When dealing with unicode input, strings.ToUpper(name[:1])+name[1:] is a broken implementation of capitalizing the first letter in a string.

However, when dealing with strictly ASCII, the code is correct, so flagging the construct could cause false positives…

Metadata

Metadata

Assignees

No one assigned

    Labels

    aggressiveA set of checks that is more prone to false positives but is helpful during code reviewneeds-decisionWe have to decide if this check is feasible and desirablenew-check

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions