atomic.LoadInt64() Function in Golang With Examples
In Go language, atomic packages supply lower-level atomic memory that is helpful is implementing synchronization algorithms. The LoadInt64() function in Go language is used to atomically loads *addr. This function is defined under the atomic package. Here, you need to import “sync/atomic” package in order to use these functions.
func LoadInt64(addr *int64) (val int64)
Here, addr indicates address.
Note: (*int64) is the pointer to a int64 value. However, int64 contains the set of all signed 64 bit integers from -9223372036854775808 to 9223372036854775807.
Return value: It returns the value loaded to the addr.
68678677 -45369087334 0 75
435 // A random value is returned in each run
In the above example, the new values returned from AddInt64() method in each call until the loop stops are stored in different addresses, LoadInt64() method returns the address of these new values. And this address can be random one so, the output of the LoadInt64() method in each run is different. So, here a random value is returned in the output.