In Go language, atomic packages supply lower-level atomic memory that is helpful is implementing synchronization algorithms. The LoadInt32() 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 LoadInt32(addr *int32) (val int32)
Here, addr indicates address.
Note: (*int32) is the pointer to a int32 value. However, int32 contains the set of all signed 32-bit integers from -2147483648 to 2147483647.
Return Value: It returns the value loaded to the addr.
57567 -842 17 3455
1416 // A random value is returned in each run
In the above example, the new values are returned from AddInt32() method in each call until the loop stops, LoadInt32() method loads these new int32 values. And these values are stored in different addresses which can be random one so, the output of the LoadInt32() method here in each run is different. So, here a random value is returned in the output.