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 17 · Apr 21 – 27, 2025

cmd/vet: flag using %s:%d to construct network addresses

Worth knowingtooling

What changed
The vet tool now warns when a format string like "%s:%d" is used with arguments whose names contain port, addr, host, listen or bind.
Production impact
The source does not say.
Try it
Run go vet ./... on a project that uses fmt.Sprintf("%s:%d", host, port) and observe the warning.
Source
github.com/golang/go/issues/28308

Understand it, then run it

Run it now

Todaygo
// This program demonstrates the new vet warning.  It uses fmt.Sprintf
// with a %s:%d format string and arguments named host and port,
// which the updated vet tool will flag when run with `go vet`.

package main

import (
	"fmt"
)

func main() {
	host := "localhost"
	port := 8080
	// The following line will trigger the vet warning in Go 1.27.1.
	addr := fmt.Sprintf("%s:%d", host, port)
	fmt.Println("Address:", addr)
}

What it printed when we ran it on Go 1.27.1

Address: localhost:8080

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