What's new in GO Version 1.19 and Its amazing features.
Go 1.19 is now available for download! The newest version of Go launched in August 2022. The critical Go 1.18 release from earlier this year is refined and improved in Go 1.19. The March 2022 Go 1.18 release was arguably monumental. It introduced many big, and much-awaited features like Generics, and fuzzing. Generics is further improved in the current version. In Go 1.19, generics development focused on fixing the nuanced bugs.
It could be said that Go 1.19 is not big on new, flashy features. However, the subtle improvements introduced in this version are expected to make coding much easier for the average developers. Additionally, they paid attention to the border issues that the ecosystem had raised.
Go 1.19 also shows significant performance enhancements. About 20% for certain generic programs, as claimed by the Go team.
New Features of Go 1.19.
As we disussed Go has Launched GO 1.19 and Here is Everything You Need to Know About It.
One aspect of Go that is always useful is that all components of the Go tool can work together. As in, Go tool format docs through go fmt, run tests through go test, and document docs with go doc. Nevertheless, the issue of go docs requiring complex formatting has often been raised. If you are wondering about doc formatting and go fmt, What is gofmt and gofmt-w-l ? would likely clear up some of your queries.
The problem surrounding complex doc formatting has been picked up and resolved in the present version of Go. In this latest version of Go, links, lists, and a cleaner header syntax are supported in doc comments. This modification makes it easier for users to provide understandable, searchable doc comments. This is particularly helpful in packages with big APIs. To improve this further, go fmt now reformats doc comments to apply uniform formatting. This allows applications of these capabilities to work even better. Not to mention, it takes away the pain of complex doc formatting from us, golang developers.
New API for Generics
Although Generics was released in Go 1.18, the integration of generics to the standard library is slow-paced. This is not at all a bad thing as it gives Go more stability and allows up an easier transition. Rolling out new APIs for generics has begun and comes as revisions in the Go Memory Model. The first API for generics in the standard library, atomic.pointer[T] is released with Go 1.19. Let us discuss this in brief.
Updates in os/exec
The exec package in GO is instrumental for running external commands. Improvements have been added to this package in Go 1.19. It does look like a small-scale improvement, but it is projected to avoid several errors associated with the exec package.
The os/exec package no longer accepts relative paths in PATH lookups to strengthen extra security purposes. Details on this can be found in the package documentation. Applications that only build using Go 1.19 or later can go back to utilizing os/exec for any existing uses of golang.org/x/sys/execabs.
Garbage Collection Guide
Go purposefully limited the amount of "knobs" available for tuning garbage collection in an attempt to preserve simplicity for the majority of us, standard Gophers. By setting GOGC, you could instruct Go to start the following cycle of garbage collection depending on how much new memory has been assigned compared to how much old memory is still available. As a result, unusual techniques were developed, such as the "memory ballast" optimization in Twitch. In this tool, they aimed to improve garbage collection by simply assigning a sizable chunk of memory that was not required.
The new garbage collection guide goes into great depth. This leans on the new soft memory limit support that the garbage collector has incorporated. Go 1.19 comes with a soft memory limit which is controllable by GOMEMLIMIT or runtime/debug.SetMemoryLimit, an environment variable. The control can be very useful for Go code optimization. This is natural because it would allow them to operate much faster in containers with allocated memory.
As we know, the OS package of GO (GOOS) is meant for creating a platform-independent interface for the functionality of the operating system. The design is GOOS is very much like UNIX.
In the latest version of GO, GOOS is claimed to be increasingly UNIX-like. For instance, when any Unix-like system is the target operating system, the new build constraint unix is satisfied. Except for windows, js, zos, and plan9, all of Go's target operating systems are now considered Unix-like.
General Performance Upgrades
Last but not least, Go 1.19 includes a wide range of output and integration modifications. These include flexible sizing of initial goroutine stacks to cut stack copying. Automatic utilization of extra file descriptors on the majority of Unix systems is now present. There is support for debugger-injected function calls on ARM64. Also, jump tables for large switch statements on x86-64 and ARM64 are here. Besides, there is registered ABI support on RISC-V. Experimental support for Linux running on the Loongson 64-bit architecture LoongArch (GOARCH=loong64) has also been incorporated.
Additional improvements such as flag.TextVar for the flag package, sort.Find for the sort package are also introduced. The flag.TextVar function is designed to allow us to make use of any type that enables encoding. It is not necessary anymore to develop an adaptor when using TextUnmarshaler directly as a flag. Meanwhile, sort.Find would help us locate items in any presorted sequence.
Wrapping it up
Go 1.19 has introduced several subtle but useful improvements. All these are targeted to performance enhancement of the language. The primary goal has been paying attention to developer feedback and existing errors. Minor updates have been added to Generics since its launch in the previous version. Additionally, doc comments now support more features. There are updates in sync/atomic and os/exec packages. The Garbage Collection Guide is also redesigned. Arguably, GOOS is now even more Unix-like. Besides these, there have been some intricate performance-enhancing updates. We believe they are likely to make big differences in output.
We are rather excited about these updates and cannot wait to get out hands on it already. Hope you enjoy them as much as we do.
Sam took the long path into the world of IT. A post-grad in Bioinformatics, she started coding to build better programs for protein sequencing. Currently, Sam actively writes blogs for 4 Way Technologies. She's always excited about all the new technologies and updates in software development. Sam also writes coding tutorials and beginners guides for, well, beginners.