Skip to content

flag: no way to access a FlagSet's output #17628

@dominikh

Description

@dominikh

The FlagSet type has a SetOutput method for setting the destination for
usage messages. This destination is used by the default Usage
function, but it's impossible to use it in custom implementations,
because no accessor for the output exists.

I propose adding a field or method to access the set output.

Relatedly, FlagSet.Usage currently writes the banner to os.Stderr,
ignoring the set output, while PrintDefaults writes to the set output.

What did you do?

https://play.golang.org/p/tDimNWwNwD

What did you expect to see?

This or similar code to compile and write to the set output

What did you see instead?

No way to do so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions