Go 1.26's Small But Clever New Function Change!

Опубликовано: 18 Март 2026
на канале: Flo Woelki
16,202
608

In this video, we will clarify what is going on with the new function in Go 1.26. If you're interested in a common performance bottleneck in Go, feel free to check out this video:    • Beware of this Struct Performance Bottlene...  


📝 Description
Clean up your Go code by discovering a small but impactful change arriving in Go 1.26 — a subtle upgrade to the built-in `new` function that eliminates boilerplate and sharpens your pointer initialization patterns. In this quick, practical tutorial, we explore Go's memory model to show exactly what `new` does under the hood, why the old syntax forced unnecessary noise into your code, and how the new expression-based syntax fixes that elegantly. By the end, you will know precisely when and why to reach for this new pattern in your own projects. Here's what you will learn:
• Understand what `new` actually does at the memory level by tracing how Go allocates, zero-initializes, and returns a pointer
• See why the old syntax forced unnecessary helper variables like `zero := 0` into otherwise clean struct initialization and table-driven tests
• Apply Go 1.26's new expression-based syntax to initialize pointers inline, without temporary variables
• Master the practical use case of pointer fields in structs for representing optional JSON and Protobuf values, where distinguishing between "zero" and "missing" is critical
• Know when this pattern pays off most — large API clients, partial PATCH handlers, and complex test setups where visual noise adds up fast


⏳ Timestamps:
00:00 - Introduction
00:16 - TL;DR
02:44 - Use case
08:15 - Adding tests
11:51 - Outro


👋 Hey there!
If you are new to this channel: Hey 👋 my name is Flo and I am a professional software engineer with a passion for coding in Golang, TypeScript, JavaScript, and Rust. This channel is where I share that passion and dive into the exciting world of software engineering.


📨 Support and Connect!
Become a member.    / @flowoelki  
Discord:   / discord  
X / Twitter: https://x.com/FlorianWoelki
LinkedIn:   / florian-woelki  
GitHub: https://github.com/FlorianWoelki


📝 Copyright Notice
The original Go Gopher was designed by Renée French (Source: https://go.dev/blog/gopher License details: https://creativecommons.org/licenses/.... The gopher appearing in this video and thumbnail is modified from the original design and based on an illustration from Maria Letta's free-gophers-pack (Source: https://github.com/MariaLetta/free-go... License: CC0 1.0 Public Domain https://creativecommons.org/publicdom....


#go #new #function