| 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 |
| 8 |
stdout 'net.JoinHostPort' |
| 9 |
|
| 10 |
# When the source is already clean, go fix -diff should print nothing |
| 11 |
# and exit with a zero code. |
| 12 |
go fix -diff example.com/clean |
| 13 |
! stdout . |
| 14 |
|
| 15 |
-- go.mod -- |
| 16 |
module example.com |
| 17 |
go 1.26 |
| 18 |
|
| 19 |
-- needsfix/x.go -- |
| 20 |
package needsfix |
| 21 |
|
| 22 |
import ( |
| 23 |
"fmt" |
| 24 |
"net" |
| 25 |
) |
| 26 |
|
| 27 |
var s string |
| 28 |
var _, _ = net.Dial("tcp", fmt.Sprintf("%s:%d", s, 80)) |
| 29 |
|
| 30 |
-- clean/x.go -- |
| 31 |
package clean |
| 32 |
|
| 33 |
import "net" |
| 34 |
|
| 35 |
var s string |
| 36 |
var _, _ = net.Dial("tcp", net.JoinHostPort(s, "80")) |