A statement or declaration ends in a semicolon that Go inserts by itself

tx0/go:stray-semicolonstrictwarningstyle

What it finds

x := f(); at the end of a line: Go inserts the semicolon at the line break anyway, so a written one is noise, a habit from other languages that gofmt removes.

A written semicolon is reported when the next token is on a later line or is the closing brace of the block. Semicolons that separate statements on one line, and those of for clauses, are left alone. The fix deletes the semicolon and is safe.

From the rule's source, stray_semicolon.rs.

Example from the rule's tests
package p func f() int {	x := 1;tx0 reports: this semicolon is inserted by Go anyway	for i := 0; i < 3; i++ {		x++	}	y := 2; z := 3	return x + y + z}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/go:stray-semicolon" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/go:stray-semicolon] reason="..."

tx0 explain tx0/go:stray-semicolon shows the same in the terminal. Found a false positive? Report it.