Re: [go-nuts] How to try out the new range func CL in a module

2023-08-27 Thread Hein Meling
Yep! Can confirm that setting GOTOOLCHAIN=local and changing the go directive in go.mod to 1.21 (without minor version) fixed the problem. Thanks again Axel! :) Hein On Monday, August 21, 2023 at 10:54:15 PM UTC-7 Axel Wagner wrote: > (or change the `go` directive to `Go 1.21` (no minor versio

[go-nuts] Re: wtf

2023-08-27 Thread Jonathan
Defer evaluates the arguments to the deferred func at the point of the defer statement. On Saturday, August 26, 2023 at 10:58:06 AM UTC-4 Aln Kapa wrote: > Hi All ! > Need some help, what am I doing wrong? > > https://go.dev/play/p/bBlA-i1CxNO > > // You can edit this code! > // Click here and

Re: [go-nuts] Is it safe to keep noCopy types in a slice which might copy on re-alloc?

2023-08-27 Thread Antonio Caceres Cabrera
Thanks for your reply, Ian. I've decided on using a []*Foo now. Just to clarify, however: In general, copying/assigning from a struct literal as in a[i] = Foo{}, is that always safe for these sync types? Or generally, is copying their "untouched" zero-values always safe? Antonio On Sunday, Augu

Re: [go-nuts] Is it safe to keep noCopy types in a slice which might copy on re-alloc?

2023-08-27 Thread Ian Lance Taylor
On Sun, Aug 27, 2023 at 7:54 AM Antonio Caceres Cabrera wrote: > > Go vet complains about this minimal example code > > type Foo struct { > val atomic.Uint64 > } > > func main() { > var foos = make([]Foo, 0) > var bar Foo > bar.val.Store(5) > foos = append(foos, bar

[go-nuts] Is it safe to keep noCopy types in a slice which might copy on re-alloc?

2023-08-27 Thread Antonio Caceres Cabrera
Go vet complains about this minimal example code type Foo struct { val atomic.Uint64 } func main() { var foos = make([]Foo, 0) var bar Foo bar.val.Store(5) foos = append(foos, bar) // call of append copies lock value: example.com/foo.Foo contains sync/atomic.U

Re: [go-nuts] wtf

2023-08-27 Thread Reto
On Sat, Aug 26, 2023 at 07:56:30AM -0700, Aln Kapa wrote: > Need some help, what am I doing wrong? You don't understand how defer works would be my guess > func main() { > Handle(true)// error > Handle(false) // no error > HandleWTF(true) // no error ? Why do you expect this to pri