This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · Archive · Week 6 · Feb 3 – 9, 2025

cmd/fix: automate migrations for simple deprecations

Worth knowingtooling

What changed
A new directive comment //go:fix inline can be placed before a function declaration to indicate that migration tooling should replace calls to that function with its body where possible.
Production impact
The source does not say.
Try it
Add //go:fix inline before a trivial function in a small package and run go fix ./... to see the replacement.
Source
github.com/golang/go/issues/32816

Understand it, then run it

Run it now

Todaygo
// This program demonstrates the new //go:fix inline directive.
// The directive is currently a no‑op for the compiler, but a future
// migration tool would replace calls to add with its body.
package main

import "fmt"

//go:fix inline
func add(a, b int) int {
	return a + b
}

func main() {
	// The call to add could be inlined by the migration tool.
	fmt.Println(add(3, 4))
}

What it printed when we ran it on Go 1.27.1

7

After the change ships

go · the proposal's code; it does not compile until the change ships

// This does not compile until the //go:fix inline directive is supported.
package main

import "fmt"

//go:fix inline
func add(a, b int) int {
	return a + b
}

func main() {
	fmt.Println(add(3, 4))
}

Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed