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

2023-08-28 Thread Ian Lance Taylor
On Sun, Aug 27, 2023 at 2:28 PM Antonio Caceres Cabrera wrote: > > 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 >

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,

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,