After the big release of Go 1.18, Go continues to develop new features.
For now, RC1 has already been released, and the version will be released in August 2022. Let’s look at what comes with Go 1.19.
Atomic Types in Go 1.19
Bool
, Int32
,Int64
, Uint32
, Uint64
, Uintptr
and Pointer
are new atomic types under sync/atomic
package. If you are unfamiliar, we could summarize the atomic package that
provides low-level atomic memory primitives useful for implementing synchronization algorithms*.
With these new types, we could use Load
,Store
, Swap
, CompareAndSwap
functions. TheAdd function is also could be used for numeric types. These functions simplify the code we have written before Go 1.19, and you can check this new code on Go Playground.
Soft Memory Limit
As you may know, when it comes to tuning memory on Go, you have only one option to set GOGC(runtime/debug.SetGCPercent)
. Even though this optimization gives a tradeoff between CPU and memory, it does not respect users’ memory limit
As described in the proposal, we could define a soft memory limit with the GOMEMLIMIT
environment variable or runtime/debug.SetMemoryLimitfunction
.
This new feature could decrease memory limits and define better memory utilization. It could be time to leave behind the memory ballast workaround the twitch team gave us🙏.
New Functions in Golang 1.19
Golang 1.19 has several changes in core libraries.
There is no ads to display, Please add some