Not using gc. You can verify that by running this under the race detector (`go run -race main.go`):
package main type A int func (A) M() {} func main() { var a A go func() { a.M() }() a = 1 } Notably, the function doesn't even have to use the receiver (in fact, the receiver is ignored in this example) for a race to trigger. I think the only way to get atomic copies would be with something like STM <https://en.wikipedia.org/wiki/Software_transactional_memory> or by guarding ~every access using a mutex transparently. i.e. you need a way to copy arbitrarily large chunks of memory atomically. On Tue, Jun 8, 2021 at 12:08 PM Ian Davis <m...@iandavis.com> wrote: > This question came to me while reading the recent thread titled "Knowing > from documentation whether an interface is holding a pointer or a struct?" > > When a method with a non-pointer receiver is called, is the copy made > atomically? My intuition says it must be but perhaps someone else can > confirm it? > > If so, how does it work? > > Ian > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/cb79c482-42ed-4213-9fc3-381f179e3fa6%40www.fastmail.com > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfESaz8LsJ2afs5yEGZK2JMbZo8%2B%2BTLq2tTx%3DXnvZKhCnA%40mail.gmail.com.