Re: [go-nuts] flag: bug with shared values?

2020-09-18 Thread Michael Jones
> 2. if other gophers has ideas of workaround? Use distinct values, but never access them directly. Write setter/getter functions that do the value sharing as you prefer and return the desired result. On Fri, Sep 18, 2020 at 11:30 AM Ian Lance Taylor wrote: > On Fri, Sep 18, 2020 at 12:50 AM

Re: [go-nuts] flag: bug with shared values?

2020-09-18 Thread Ian Lance Taylor
On Fri, Sep 18, 2020 at 12:50 AM Manfred Touron wrote: > > 1. if I need to open an issue or not on the go repo, if the fix is not about > code, it can be about doc maybe? Documentation fixes are always welcome. You can open an issue or just send a change. > 2. if other gophers has ideas of wor

Re: [go-nuts] flag: bug with shared values?

2020-09-18 Thread Manfred Touron
There are actually multiple cases of reusing the same XXXVar for the same variables: * https://github.com/golang/go/blob/50bd1c4d4eb4fac8ddeb5f063c099daccfb71b26/src/flag/example_test.go#L29-L30 -> to support shortcuts within the same command * projects with multiple flag.FlagSet (to manage va

Re: [go-nuts] flag: bug with shared values?

2020-09-17 Thread Ian Lance Taylor
On Thu, Sep 17, 2020 at 5:04 PM Manfred Touron wrote: > > I think that I discovered a bug in the stdlib flag package: > > sharedFlag := "init-value" > fooFs := flag.NewFlagSet("foo", flag.ContinueOnError) > barFs := flag.NewFlagSet("bar", flag.ContinueOnError) > fooFs.StringVar(&sh

[go-nuts] flag: bug with shared values?

2020-09-17 Thread Manfred Touron
Hi, I think that I discovered a bug in the stdlib flag package: sharedFlag := "init-value" fooFs := flag.NewFlagSet("foo", flag.ContinueOnError) barFs := flag.NewFlagSet("bar", flag.ContinueOnError) fooFs.StringVar(&sharedFlag, "baz", "foo-default", "testing") barFs.StringVar(