In Golang there are sync.Mutex, sync.Atomic and Channels to create this fence and prevent data races. I prefer sync.Mutex.

Does anyone understand how Go handles the CPU cache?

Yes. Locks will use a memory fence. More advanced programs will need fence without locking.

[deleted]