1 # Regression test for go.dev/issue/82758: the export data that vet
2 # writes to the .vetx file of a cgo package must not depend on the
3 # name of the work directory, which varies from run to run.
4
5 [!cgo] skip
6 [short] skip 'runs vet on a cgo package'
7
8 env GOCACHE=$WORK/gocache
9 go vet ./u
10
11 # Recomputing the vet actions yields identical outputs.
12 env GODEBUG=gocacheverify=1
13 go vet ./u
14 ! stderr 'cache verify failed'
15 env GODEBUG=
16
17 # Diagnostics in the files of a cgo package are still reported
18 # relative to the package directory.
19 ! go vet ./bad
20 stderr '^bad[/\\]bad\.go:9:\d+: fmt\.Sprintf format %d has arg "x" of wrong type string$'
21
22 -- go.mod --
23 module m
24
25 go 1.26
26 -- c/c.go --
27 package c
28
29 /*
30 struct x { int a; };
31 */
32 import "C"
33
34 type T struct{ p *C.struct_x }
35 -- u/u.go --
36 package u
37
38 import "m/c"
39
40 var V c.T
41 -- bad/bad.go --
42 package bad
43
44 /*
45 int f(void) { return 0; }
46 */
47 import "C"
48 import "fmt"
49
50 var _ = fmt.Sprintf("%d", "x") + fmt.Sprint(C.f())
51
View as plain text