Urgent.News

What's breaking now, across thousands of outlets.

Tech

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

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…

Go 1.26 introduced a new feature called go fix, which automates the process of updating deprecated API calls to their new counterparts. When a library author marks a function as deprecated, they can use a //go:fix inline directive to instruct go fix to rewrite all call sites to the new API. The directive consists of a comment on the old function, allowing the inliner to automatically update the code.

The inliner takes the body of the deprecated function and inlines it into each call site, replacing the parameters with the corresponding arguments. In the example provided, the money package in example.com/shop deprecated the FormatCents function and replaced it with a new Format function that accepts a Locale parameter. The inliner then updated all calls to FormatCents to use Format with the DefaultLocale.

This feature simplifies the process of migrating code to new APIs, reducing the burden on downstream users who would otherwise have to manually update each call site.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Find Broken Pages on Your Site From Its Sitemap, With One Python File

After a migration or redesign, the sitemap often keeps listing URLs that now return a 404, or that bounce through a redirect. Search engines notice before you do, and so do visitors. Online link checkers work, but many cap the page count, want an account, or can't be scripted.

  • Python script 'sitemap-link-checker' scans sitemaps for broken links
  • Detects 404 errors, 301 redirects, and dead links in one run
  • MIT open-source license available on Hermes-skills GitHub repository

More from Sunday 1 November →