File tree 1 file changed +18
-0
lines changed
src/go/internal/srcimporter
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
"go/types"
11
11
"internal/testenv"
12
12
"io/ioutil"
13
+ "os"
13
14
"path"
14
15
"path/filepath"
15
16
"runtime"
@@ -18,6 +19,23 @@ import (
18
19
"time"
19
20
)
20
21
22
+ func TestMain (m * testing.M ) {
23
+ // Add -mod=vendor to GOFLAGS to ensure that we don't fetch modules while importing std or cmd.
24
+ //
25
+ // TODO(golang.org/issue/30240): If we load go.mod files from vendor/
26
+ // automatically, this will probably no longer be necessary.
27
+ var goflags []string
28
+ for _ , f := range strings .Fields (os .Getenv ("GOFLAGS" )) {
29
+ if ! strings .HasPrefix (f , "-mod=" ) && ! strings .HasPrefix (f , "--mod=" ) {
30
+ goflags = append (goflags , f )
31
+ }
32
+ }
33
+ goflags = append (goflags , "-mod=vendor" )
34
+ os .Setenv ("GOFLAGS" , strings .Join (goflags , " " ))
35
+
36
+ os .Exit (m .Run ())
37
+ }
38
+
21
39
const maxTime = 2 * time .Second
22
40
23
41
var importer = New (& build .Default , token .NewFileSet (), make (map [string ]* types.Package ))
You can’t perform that action at this time.
0 commit comments