Go 1.26 Introduces Source-Level Inliner for Self-Service API Migrations
The Go programming language team has announced a significant update in Go 1.26, featuring a new implementation of the go fix subcommand designed to modernize codebases efficiently. Central to this update is the source-level inliner, a tool that allows package authors to facilitate safe API migrations using the //go:fix inline directive. Unlike compiler inlining, which optimizes intermediate representations, this feature durably modifies source code by replacing function calls with their bodies. This ensures behavioral consistency while updating deprecated functions, such as replacing ioutil.ReadFile with os.ReadFile. The inliner serves as a foundational block for self-service modernizers, enabling developers to express simple API updates without complex rewrite rules. By automating these transformations, Go 1.26 aims to help maintainers keep their code up-to-date with minimal manual intervention. This approach leverages existing refactoring capabilities from gopls, addressing subtle correctness issues during function signature changes. The update represents a shift towards empowering library authors to provide direct migration paths, reducing the burden on users when adopting new library versions or language features.
Wire timeline
Go 1.26 Introduces Source-Level Inliner for Self-Service API Migrations
The Go programming language team has announced a significant update in Go 1.26, featuring a new implementation of the go fix subcommand designed to modernize codebases efficiently. Central to this update is the source-level inliner, a tool that allows package authors to facilitate safe API migrations using the //go:fix inline directive. Unlike compiler inlining, which optimizes intermediate representations, this feature durably modifies source code by replacing function calls with their bodies. This ensures behavioral consistency while updating deprecated functions, such as replacing ioutil.ReadFile with os.ReadFile. The inliner serves as a foundational block for self-service modernizers, enabling developers to express simple API updates without complex rewrite rules. By automating these transformations, Go 1.26 aims to help maintainers keep their code up-to-date with minimal manual intervention. This approach leverages existing refactoring capabilities from gopls, addressing subtle correctness issues during function signature changes. The update represents a shift towards empowering library authors to provide direct migration paths, reducing the burden on users when adopting new library versions or language features.
The Go Blog