getopt icon indicating copy to clipboard operation
getopt copied to clipboard

Visit() does not work

Open Vovan-VE opened this issue 4 years ago • 2 comments

Hello!

I'm trying to combine this package with a solution from this answer:

func isFlagPassed(name string) bool {
    found := false
    flag.Visit(func(f *flag.Flag) {
        if f.Name == name {
            found = true
        }
    })
    return found
}

Unfortunely, it does not work, because getopt.Parse() doesn't update underlying flag.FlagSet.actual. I know it cannot do it directly. But the fact is that Visit() does not work AND this is not documented.

Vovan-VE avatar Jan 23 '21 06:01 Vovan-VE

@Vovan-VE were you able to make it work, if not, what did you do instead?

Chaitanyabsprip avatar Apr 29 '24 14:04 Chaitanyabsprip

@Chaitanyabsprip , I already forget about this. I used https://github.com/alexflint/go-arg last time.

Vovan-VE avatar Apr 29 '24 14:04 Vovan-VE