...
1# Test that go fix skips fixes to non-main and/or vendored packages.
2# (It uses the interface{} -> any modernizer.)
3
4# Create vendor tree programmatically to avoid
5# having to hardcode sums in this txtar archive.
6go mod vendor
7
8# Show fixes on two packages, one in the main module
9# and one in a vendored dependency.
10# Only the main one (a) is shown.
11go fix -diff example.com/a example.com/b
12stdout 'a[/\\]a.go'
13stdout '\-var _ interface\{\}'
14stdout '\+var _ any'
15! stdout 'b[/\\]b.go'
16
17# Apply fixes to the same two packages.
18# Only the main module was modified.
19go fix example.com/a example.com/b
20grep 'var _ any' a/a.go
21grep 'var _ interface{}' b/b.go
22grep 'var _ interface{}' vendor/example.com/b/b.go
23
24-- go.mod --
25module example.com
26go 1.26
27
28require "example.com/b" v0.0.0
29replace "example.com/b" => ./b
30
31-- a/a.go --
32package a
33
34import _ "example.com/b"
35
36var _ interface{}
37
38-- b/go.mod --
39module example.com/b
40
41-- b/b.go --
42package b
43
44var _ interface{}
View as plain text