Skip to content

MarkDeprecated and NormalizeFunc as alias results in an inconsistent deprecation message #279

Open

Description

@andersjanmyr
cmd.Flags().StringVar(&src, "dir", "", "deprecated, use src")
cmd.Flags().MarkDeprecated("dir", "dir has been renamed src")
cmd.Flags().StringVar(&src, "src", "", "src directory or file")
cmd.Flags().SetNormalizeFunc(aliasNormalizeFunc)
$ go run . --dir=test
Flag --src has been deprecated, dir has been renamed src

Activity

  1. tomasaschan commented on Jul 16, 2025

    @tomasaschan
    Collaborator

    This issue has not been updated in a long time. Is it still relevant?

    (If I receive no answer before the end of the summer, I'll close it. Feel free to re-open if you come here after that happens and it is relevant to you - but if you do, please also comment and specify what outcome you're interested in!)

  2. hdimer commented on Jul 30, 2026

    @hdimer

    Still reproduces on main. With an alias set up via SetNormalizeFunc, using the alias for a deprecated flag reports the canonical name instead of the one you typed:

    $ go run . --dir=test
    Flag --src has been deprecated, dir has been renamed src
    

    Parse passes the normalized flag.Name into Set, so the typed name is lost before the message is built. Outcome I'd want: report the flag as typed, Flag --dir has been deprecated, .... Opened #500 with a small fix.

  3. added a commit that references this issue on Oct 16, 2026
    6f1cdf1
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions