Re: [go-nuts] goroutine private / local var/const

2022-07-20 Thread Konstantin Khomoutov
On Wed, Jul 20, 2022 at 01:00:59PM +0300, Konstantin Khomoutov wrote: > > for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ > > fmt.Println("f:beg i=",i) // here c or v instead > > // action > > fmt.Println("f:end i=",i) // here c or v instead > > }} [...] > - Make your anonymous

Re: [go-nuts] goroutine private / local var/const

2022-07-20 Thread Konstantin Khomoutov
On Tue, Jul 19, 2022 at 08:28:02AM -0700, 'andreas graeper' via golang-nuts wrote: > for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ > fmt.Println("f:beg i=",i) // here c or v instead > // action > fmt.Println("f:end i=",i) // here c or v instead > }} > when this routines get inte

[go-nuts] goroutine private / local var/const

2022-07-19 Thread 'andreas graeper' via golang-nuts
hi, for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ fmt.Println("f:beg i=",i) // here c or v instead // action fmt.Println("f:end i=",i) // here c or v instead }} when this routines get interrupted then beg-i and end-i differ now i want at the beginning of the routine a const copy