Go 1.26: Demystifying the Source-Level Inliner
Explains Go's source-level inliner in Q&A format: how it works, differs from compiler inlining, usage in gopls/go fix, and benefits for refactoring and API migrations.
Go 1.26 introduces a revamped go fix command that helps keep your code modern and up‑to‑date. One of its standout features is the source‑level inliner—a tool that can rewrite function calls inline directly in your source files. Originally built for gopls refactorings, this inliner now powers self‑service API migrations and upgrades. Let’s explore how it works, what makes it different from compiler inlining, and how you can use it to simplify your codebase.
What is the source‑level inliner?
The source‑level inliner is a tool that replaces a function call with a copy of the function’s body, substituting the actual arguments for the parameters. Unlike compiler inlining, which operates on an internal representation to optimize performance, this transformation modifies your actual source code. It was first developed in 2023 and is now part of go fix and gopls. For example, calling sum(1,2,3) inside a function six can be inlined to 1+2+3, removing the function call entirely.

How does source‑level inlining differ from compiler inlining?
Compiler inlining happens automatically during compilation: the compiler decides which calls to inline based on heuristics, and it inserts the function body into the generated machine code. The original source code stays unchanged. Source‑level inlining, on the other hand, durably rewrites the source files. It replaces the call site with the function’s code, making the change visible in your text editor and version control. This is a refactoring operation, not an optimization. It gives you control over when and how to inline calls, and it can be undone or reviewed like any other code change.
How can I use the source‑level inliner in gopls?
If you use VS Code with the Go extension, you can trigger the inliner by selecting a function call and choosing “Source Action… > Inline call” from the context menu. In other editors with gopls support, the same action is available under the refactoring menu. The inliner will analyze the call, handle variadic arguments, side effects, and multiple return values, and then modify the source file in place. The visual editor shows a before‑and‑after preview, making it easy to verify the transformation is correct before accepting it.
Why is the source‑level inliner important for refactoring?
Many refactorings—like changing a function’s signature or removing an unused parameter—require modifying every call site. The inliner simplifies this by first inlining all calls, then adjusting the result. It correctly renames identifiers, duplicates side‑effectful arguments, and keeps the code semantically equivalent. Without it, manual refactoring is error‑prone, especially when arguments have side effects or are used multiple times. The inliner automates these tricky transformations, making large‑scale refactors safer and faster.
What role does the source‑level inliner play in go fix?
In Go 1.26, go fix includes the source‑level inliner as one of its built‑in analyzers. This empowers package authors to define their own “modernizers” that automatically update API usage. For example, if a library deprecates a function and introduces a new one, the inliner can rewrite calls to the old function into inline code that uses the new API. This self‑service mechanism reduces the maintenance burden on library developers and helps users migrate without manual intervention.

How does the inliner enable self‑service API migrations?
Self‑service migrations work through a special //go:fix inline directive. Package authors can add this directive to a function—indicating that any call to it should be inlined by go fix. When a user runs go fix ./... on their project, the tool automatically inlines all such calls, substituting the function body and arguments. The user gets a source‑level transformation they can review and commit. This approach scales because library authors specify the migration once, and all downstream consumers benefit from it.
What algorithm powers the source‑level inliner?
The inliner is built on an algorithm designed to handle all the edge cases of Go’s calling conventions. It correctly manages variadic parameters, multiple return values, and side effects (such as arguments that mutate state). The algorithm also deals with identifier collisions and ensures that the inlined code works correctly in every context. It was developed in 2023 and has been battle‑tested in gopls before being integrated into go fix. For a deep dive, see the original blog post from March 2026 (or consult the Go source code).
What are the benefits of using the source‑level inliner?
The main benefits are safer refactoring, easier API migrations, and cleaner code. By inlining, you can remove unnecessary function calls, eliminate indirection, and make the logic more explicit. The tool automates a task that would otherwise be tedious and error‑prone. For package authors, it provides a powerful way to update their users’ code without breaking changes. For everyday Go developers, it integrates seamlessly into existing workflows via gopls and go fix, making your codebase more maintainable with minimal effort.