...
1# Test that go fix -diff exits with non-zero status when diffs exist,
2# and exits with zero status when no diffs are needed.
3# This is consistent with gofmt -d (#46289) and go mod tidy -diff (#27005).
4
5# When the source needs fixes, go fix -diff should print the diff
6# and exit with a non-zero code.
7! go fix -diff example.com/needsfix
8stdout 'net.JoinHostPort'
9
10# When the source is already clean, go fix -diff should print nothing
11# and exit with a zero code.
12go fix -diff example.com/clean
13! stdout .
14
15-- go.mod --
16module example.com
17go 1.26
18
19-- needsfix/x.go --
20package needsfix
21
22import (
23 "fmt"
24 "net"
25)
26
27var s string
28var _, _ = net.Dial("tcp", fmt.Sprintf("%s:%d", s, 80))
29
30-- clean/x.go --
31package clean
32
33import "net"
34
35var s string
36var _, _ = net.Dial("tcp", net.JoinHostPort(s, "80"))
View as plain text