After the big bang of Go 1.18, Go still continues to develop new features. If you miss what comes with 1.18, check my previous Quick Guide. 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.
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
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 basically 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
With this new feature, we 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🙏.
Go 1.19 has several changes in core libraries. When I checked those, I select some of them seems significant to me.
fmthas new functions for appending data.
sort.Findis a new function for finding the smallest index of i with given comparator function. It offers better experience than
- Sorting algorithms switched to pattern-defeating quicksort for faster results for several scenarios.
URL.JoinPathmethod) creates a new URL by joining a list of path elements.
Unix build constraint
unix is a new build constraint that is satisfied if
GOOS is one of
ios, linux, android, darwin, dragonfly, freebsd, hurd, illumos, netbsd, aix, openbsd or solaris
The compiler now uses a jump table to implement large integer and string switch statements. Performance improvements for the switch statement vary but can be on the order of 20% faster. (
You could check this benchmark for details.
With 1.19 version, the community works well and takes care of several performance optimizations. Many improvements and fixes will also be in this version. Those features are my selections. If I missed any fancy features, please contact me.
If you like to join our Gophers, you could apply for our open positions.