Go 1.26 Unveils Source-Level Inliner: A Self-Service Modernization Breakthrough for Developers
By • min read
<h2>Revolutionizing Go Code Updates: Source-Level Inliner Goes Live in Go 1.26</h2><p>The Go team has released a groundbreaking enhancement to the <code>go fix</code> tool in version 1.26, introducing a source-level inliner that lets package authors automate API migrations and upgrades with unprecedented ease. This marks a major shift in how developers keep their codebases current, moving from manual updates to self-service modernization.</p><figure style="margin:20px 0"><img src="/gopls/assets/inline-before.png" alt="Go 1.26 Unveils Source-Level Inliner: A Self-Service Modernization Breakthrough for Developers" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: blog.golang.org</figcaption></figure><p>“The source-level inliner is the first fruit of our efforts to provide self-service modernizers and analyzers,” said Alan Donovan, a core Go team member. “It enables any package author to express simple API migrations and updates in a straightforward and safe way.”</p><h2>How the Source-Level Inliner Works</h2><p>The new inliner replaces a function call with a copy of the called function’s body, substituting arguments for parameters directly in the source code. This durable source-level transformation distinguishes it from compiler inlining, which operates on temporary internal representations for performance optimization.</p><p>Developers who have used the “Inline call” refactoring in <a href="https://gopls.dev">gopls</a> (available in VS Code under Source Action) have already experienced this technology. The before-and-after snapshots below show how a call to <code>sum</code> inside function <code>six</code> gets replaced by the inline code:</p><figure class="beforeafter"><pre class="old">func six() int {
return sum(1, 5)
}</pre><span class="beforeafter-arrow"></span><pre class="new">func six() int {
return 1 + 5
}</pre><figcaption>Before and after inlining the call to <code>sum</code>.</figcaption></figure><p>This inliner handles subtle correctness issues automatically, such as shadowing of variables, side effects, and multiple returns. It’s already powering other refactorings like “Change signature” and “Remove unused parameter” inside gopls.</p><h2>Background: From Manual Fixes to Self-Service</h2><p id="background">Historically, <code>go fix</code> offered bespoke modernizers for specific language or library features, requiring the Go team to write a separate tool for each change. This approach scaled poorly as the language evolved.</p><p>With Go 1.26, the team rebuilt <code>go fix</code> from the ground up. The source-level inliner is the first of a new class of “self-service” analyzers that let any package author define migration rules without waiting for official tooling.</p><figure style="margin:20px 0"><img src="https://go.dev/gopls/assets/inline-before.png" alt="Go 1.26 Unveils Source-Level Inliner: A Self-Service Modernization Breakthrough for Developers" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: blog.golang.org</figcaption></figure><p>“It’s a crucial building block for many source transformation tools,” Donovan explained. “It takes care of many subtle correctness issues that arise when refactoring function calls.”</p><h2>What This Means for Go Developers</h2><p id="what-this-means">The immediate impact is faster, safer code updates. Package authors can now encode their own API migration recipes, enabling users to upgrade to new library versions automatically by running <code>go fix</code>.</p><p>For example, if a library deprecates a function in favor of a simpler alternative, the package maintainer can supply an inline directive that <code>go fix</code> will apply across the entire codebase—reducing manual effort and the risk of human error.</p><p>Longer term, this lays the foundation for a broader ecosystem of analyzers and modernizers. Developers can expect more declarative fix patterns, longer migration windows, and less friction when adopting new Go features.</p><p><strong>Urgent action:</strong> Teams using older Go versions should plan an upgrade to 1.26 to leverage this capability. The source-level inliner is available now in the <a href="https://go.dev/dl/">Go 1.26 beta</a>.</p><h2>Get Started Today</h2><p>To try it, upgrade to Go 1.26 and run <code>go fix ./...</code> on your project. Look for inline directives in third-party packages or <a href="https://go.dev/doc/modules/go-fix">read the official documentation</a> to create your own. The future of Go code modernization is self-service—and it’s here now.</p>