Menu

1 / 3

Deprecate a Go Function and Let go fix Migrate Every Caller With //go:fix inline

DEV Community: go·Gabriel Anhaia·15 days ago
#VMQv3hPR
#devtogo#devto#dev#cents#inline
Reading 0:00
15s threshold

Book: The Complete Guide to Go Programming

Also by me: Pocket Guides for Developers — the 8-book series

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

ioutil.ReadFile has been a one-line wrapper around os.ReadFile since Go 1.16. Its doc comment carries a Deprecated: line that points you at os.ReadFile . For years that comment made linters complain and never moved a single call site.

You know the library-author version of this. You ship v1.4.0 with a better API, mark the old function Deprecated: , and then watch the old one get called for the next three years because nobody downstream has a free afternoon to rewrite fifty call sites by hand.

Go 1.26 changed the deal. The release notes describe a completely rebuilt go fix that includes "a source-level inliner that allows users to automate their own API migrations using //go:fix inline directives." You put one comment on the old function.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.