Skip to content

Build Not yet confirmed elsewhere1 publisher 2 min read Published

Go teams can drop ptr[T] helpers now that Go 1.26 lets new() take an expression

Go 1.26, released February 10, 2026, lets the built-in new() take an expression such as new(42) or new(time.Now()). Teams with ptr[T] or StringPtr helpers can preview a rewrite with go fix -diff -newexpr before deleting anything.

The Engineer · Build desk

How we use AI Send a correction

Illustration accompanying Go teams can drop ptr[T] helpers now that Go 1.26 lets new() take an expression
Generated illustration
Go pointer-expression issue opened in 2021 Dates the story reports for golang/go#45624 and for the Go 1.26 and Go 1.27 releases.

Timeline: April 2021, Rob Pike opens golang/go#45624, 'spec: expression to create pointer to simple types', as an alternative to #9097; February 10, 2026, Go 1.26 is released and new accepts an expression; August 19, 2026, Go 1.27 is out with no change to new(expr), per the post.

Go pointer-expression issue opened in 2021
DateEventClaim
April 2021Rob Pike opens golang/go#45624, an alternative to #90972
February 10, 2026Go 1.26 released; new now accepts an expression1
August 19, 2026Go 1.27 out, no change to new(expr), per the post15

What happened

  • The spec's Allocation section now defines new(x) as allocating a variable of x's type, initialized to the value of x.
  • The change closes golang/go#45624, opened by Rob Pike in April 2021 as an alternative to older proposal #9097 and closed by Alan Donovan in October 2025.
  • Go 1.26 also rewrote go fix as the home of Go's modernizers, and its newexpr analyzer targets the pointer-helper pattern.

Why it matters

  • constraint Library authors pay for the cleanup in compatibility. Bumping the go directive sets a new minimum Go version for every importer, and the post says that is where the old helper still wins.
  • decision Whether a shared pointer package can be deleted outright depends on its bodies. Only single-return helpers match the analyzer's rule, so any helper with extra logic stays a manual migration.
  • capability An unset-versus-zero field can now be written inline. new(0) gives a non-nil pointer to 0, which omitempty keeps, so no function is needed to get "retries":0 into the JSON.

The helper existed because Go will not take the address of a constant or a call result. &42 and &time.Now() do not compile [6]. Go also has no Optional[T], so a field that must tell absent from zero is usually a pointer [7]. With omitempty, a nil pointer is dropped and a non-nil pointer to 0 is kept, so a Retries field set to a pointer to 0 serializes as "retries":0 [10]. The Go 1.26 release notes, as the post quotes them, call the feature "particularly useful when working with serialization packages such as encoding/json or protocol buffers that use a pointer to represent an optional value." [8]

Everyone wrote the same function. The post lists proto.String and proto.Int64 in protobuf-go, ptr.To in k8s.io/utils and ToPtr in samber/lo [9]. The protobuf ones are a single line each [11]. Donovan signed off the issue with "All done, in only eleven years since #9097. ;-)" [3].

Until 1.26, new took only a type. Now it accepts an expression [1]. The post says the behavior matches the helper's [12]. new(int) still returns a pointer to 0, new(123) returns a pointer to 123, and both are *int [5].

The adoption cost is the language version. Either the module or, via a build constraint, the individual file must declare at least Go 1.26, so a go.mod that says go 1.25 needs go mod edit -go=1.26 [13]. That raises the minimum Go version for everyone who imports the module. The post calls that usually fine for an application and a decision for a library, and names the library as the first case where the old helper wins [14]. Go 1.27, out since August 19, 2026, changes nothing about new(expr), the post says, so either release works [15].

For call sites, go fix -diff -newexpr ./... previews the rewrite and go fix -newexpr ./... applies it [17]. The newexpr analyzer looks for "new-like" functions: exactly one parameter, not variadic, a single pointer result, and nothing in the body but return &param [18]. In the post author's reading of the source, a generic ptr[T] should qualify, because the match is on the parameter itself [19]. Any helper with a different body falls outside that definition [20].

The text available to us ends partway through the analyzer's description, so what newexpr does with the helper's own declaration is unconfirmed. The author hedges the headline claim: "you can likely delete most of it now, and go fix will do the bulk of the work." [21]

What to watch

  • The full output of go tool fix help newexpr, which should show whether the fixer also removes the helper's own declaration.
  • Whether protobuf-go, k8s.io/utils and samber/lo change their one-line pointer helpers.
  • Which library maintainers raise their go directive to 1.26 and which keep the helper to hold a lower minimum.

Clarity's read

What the record supports and how the coverage leans. The claims behind it follow.

Reality

Evidence62
Adoption
Insufficient
Hype gap+10
Incentives
Insufficient
Confidence60
Why these scores

Claim ledger

Ranked by verification strength, evidence, and original report placement.

  1. [1]

    Go 1.26 was released on February 10, 2026. The built-in new now accepts an expression, not only a type; new(42) and new(time.Now()) compile.

    Reported SupportedView cited source
  2. [2]

    In April 2021 Rob Pike opened golang/go#45624, 'spec: expression to create pointer to simple types', as an alternative to an older proposal, #9097; Alan Donovan closed the issue in October 2025.

    Reported SupportedView cited source
  3. [3]

    Alan Donovan signed off the issue with the joke: "All done, in only eleven years since #9097. ;-)"

    Reported Supported Source: Alan Donovan, as quoted in the dev.to postView cited source

Get this ledger inside ChatGPT. Ask about any of our stories and the answer brings its figure, each claim’s verdict and the sources. Free, no account.

Add to ChatGPTAdd to Claude

Sources

1 independent publisher whose own reporting we read for this story.

  1. dev.to

    1 article · October 14, 2026

    Go 1.26 Lets new() Take an Expression. Delete Your Pointer Helpers

Share your take

Let Clarity write the post for you.

Signed-in readers get a short post drafted on this story in the register they choose — narrative, analytical, or a direct position — editable to the last word before it goes anywhere. The share buttons at the top of this story work without an account.

Topics and entities

Follow any of these and your For You feed starts watching them — no settings page required.

Topics

Entities

Loading related stories