Go 1.26: Built-in new() Now Accepts Expressions
Released on February 10, 2026, Go 1.26 allows the built-in new() function to accept expressions directly, enabling developers to remove old pointer helpers.

Stock photo for illustration only, not from the actual event
- Go 1.26 released on February 10, 2026, lets new() accept expressions
- Eliminates the need for custom pointer helpers like ptr[T] or IntPtr
- New go fix tool automates the migration process across codebases
- Certain edge cases still require traditional helper functions to remain
The Go programming language received a major update in Go 1.26, released on February 10, 2026, bringing a significant enhancement to the built-in new() function. Instead of being restricted to accepting only types, new() now accepts expressions directly, meaning expressions like new(42) or new(time.Now()) compile successfully out of the box.
This update directly impacts codebases that rely on custom pointer helpers such as ptr[T], StringPtr, IntPtr, or a utils/pointer.go file imported across packages. Developers can now delete most of these utilities, letting the go fix tool handle the heavy lifting once their go.mod file specifies Go 1.26 or later.

Stock photo for illustration only, not from the actual event
Go lacks a native Optional[T] type, meaning absent fields that differ from zero values are conventionally handled using pointers. The Go 1.26 release notes explicitly highlight that this feature is particularly useful when working with serialization packages like encoding/json or protocol buffers that utilize pointers to represent optional values.
To refactor codebases efficiently, Go 1.26 overhauls go fix using the same analysis framework as go vet. A dedicated analyzer named newexpr targets this specific pattern. Alan Donovan's post on the Go blog outlines commands like go fix -diff -newexpr ./... to preview changes before applying the fixer and running it multiple times until completion.
This language enhancement demonstrates the Go team's ongoing commitment to reducing boilerplate code that developers have written repeatedly for years. While syntactically minor, it substantially lowers maintenance overhead for modern codebases. Library authors, however, must carefully weigh the decision of bumping their minimum required Go version against backwards compatibility for users on older releases.
The go fix utility intentionally skips rewrites when type safety could be compromised, such as with untyped constants carrying non-default types or shadowed new declarations. Furthermore, traditional helpers remain necessary when passing function values, maintaining compatibility with pre-1.26 Go versions, or handling read-side operations like retrieving optional fields with default values using pointer dereference helpers.
Source: Dev.to
Found something wrong in this article? Report an issue with this article
Comments
Leave a Comment