8000 staticcheck: flag strings.ToUpper(name[:1])+name[1:] · Issue #517 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

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

Open

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…

Activity

  1. changed the title [-]strings.ToUpper(name[:1])+name[1:][/-] [+]staticcheck: flag strings.ToUpper(name[:1])+name[1:][/+] on Jun 15, 2019
  2. added
    needs-decisionWe have to decide if this check is feasible and desirable
    and removed
    needs-triageNewly filed issue that needs triage
    on Jun 15, 2019
  3. added
    aggressiveA set of checks that is more prone to false positives but is helpful during code review
    on Nov 14, 2021
  4. added this to the Staticcheck 2022.2 milestone on Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0