Skip to content

cmd/fix: go fix and go fix -diff report the "reverse" results #78167

@thaJeztah

Description

@thaJeztah

Go version

go version go1.26.1 darwin/arm64

Output of go env in your module/workspace:

not relevant

What did you do?

This is really a "nit" 🙈 and maybe it was by design but I noticed it when updating some of my examples; it looks like go fix and go fix -diff are inconsistent and report the exact reverse of changed made.

Feel free to close this one if this was by design! ❤️ - if it was not by design, I'm happy to look at contributing a change 👍

Without -diff, go fix reports the number of fixes applied:

fix: applied 2 of 3 fixes; 1 file updated. (Re-run the command to apply more.)

With -diff, go fix reports the number of fixes skipped;

fix: 1 of 3 fixes skipped (e.g. due to conflicts)

What did you see happen?

With -diff:

go fix -mod=readonly -diff ./... > /dev/null
# example.com/f
# [example.com/f]
fix: 1 of 3 fixes skipped (e.g. due to conflicts)
# example.com/g
# [example.com/g]
fix: 1 of 3 fixes skipped (e.g. due to conflicts)
# example.com/h
# [example.com/h]
fix: 1 of 2 fixes skipped (e.g. due to conflicts)
# example.com/i
# [example.com/i]
fix: 2 of 3 fixes skipped (e.g. due to conflicts)
# example.com/j
# [example.com/j]
fix: 2 of 3 fixes skipped (e.g. due to conflicts)
# example.com/k_test
# [example.com/k_test]
fix: 1 of 2 fixes skipped (e.g. due to conflicts)

Running the same without -diff reports the exact reverse;

go fix -mod=readonly ./...
# example.com/f
# [example.com/f]
fix: applied 2 of 3 fixes; 1 file updated. (Re-run the command to apply more.)
# example.com/g
# [example.com/g]
fix: applied 2 of 3 fixes; 2 files updated. (Re-run the command to apply more.)
# example.com/h
# [example.com/h]
fix: applied 1 of 2 fixes; 1 file updated. (Re-run the command to apply more.)
# example.com/i
# [example.com/i]
fix: applied 1 of 3 fixes; 1 file updated. (Re-run the command to apply more.)
# example.com/j
# [example.com/j]
fix: applied 1 of 3 fixes; 1 file updated. (Re-run the command to apply more.)
# example.com/k_test
# [example.com/k_test]
fix: applied 1 of 2 fixes; 1 file updated. (Re-run the command to apply more.)

What did you expect to see?

Both to report the same 😅 - perhaps a combination of the two ("applied X fixes" is a more positive message and "re-run the command" makes it (potentially) actionable); something like...

fix: 1 file updated: applied 2 of 3 fixes, skipped 1 (e.g., due to conflicts); re-run the command to apply more.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions