Go 1.26 introduces a source-level inliner as part of the redesigned `go fix` command, enabling self-service API migrations. By annotating deprecated functions with `//go:fix inline`, package authors can instruct the tool to automatically replace calls to old functions with their new equivalents. The post explains how the inliner works and covers six key technical challenges it must handle correctly: parameter elimination, side effects and evaluation order, fallible constant expressions, variable shadowing, unused variables, and defer statements. The inliner is already integrated into gopls for interactive use and has been used to prepare over 18,000 changelists in Google's monorepo.

16m read timeFrom go.dev
Post cover image
Table of contents
Source-level inlining ¶Under the hood of the inliner ¶Try it out! ¶

Sort: