Skip to content

fix order of arguments in new functions .Func() and .BoolFunc() #433

@LeGEC

Description

@LeGEC

following !429 : an unfortunate discrepancy landed in the order of arguments for the new functions .BoolFunc() and .Func():

// BoolFunc:
func (f *FlagSet) BoolFunc(name string, usage string, fn func(string) error) {
func (f *FlagSet) BoolFuncP(name, shorthand string, usage string, fn func(string) error) {

func BoolFunc(name string, usage string, fn func(string) error) {
func BoolFuncP(name, shorthand string, fn func(string) error, usage string) {  // <- 'fn' value appears before 'usage' string

// Func:
func (f *FlagSet) Func(name string, usage string, fn func(string) error) {
func (f *FlagSet) FuncP(name string, shorthand string, usage string, fn func(string) error) {

func Func(name string, fn func(string) error, usage string) {  // <- 'fn' value appears before 'usage' string
func FuncP(name, shorthand string, fn func(string) error, usage string) {  // <- 'fn' value appears before 'usage' string

taking the flag package from the stdlib as a reference, the order of arguments should always be name(s), usage, fn. (node: the link to go code reflects the state of master branch on 2025-06-27)

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