@@ -32,6 +32,12 @@ func Extract(patterns []string) error {
32
32
33
33
// ExtractWithFlags extracts the packages specified by the given patterns and build flags
34
34
func ExtractWithFlags (buildFlags []string , patterns []string ) error {
35
+ modEnabled := os .Getenv ("GO111MODULE" ) != "off"
36
+ if ! modEnabled {
37
+ log .Println ("Go module mode disabled." )
38
+ }
39
+
40
+ log .Println ("Running packages.Load." )
35
41
cfg := & packages.Config {
36
42
Mode : packages .NeedName | packages .NeedFiles |
37
43
packages .NeedCompiledGoFiles |
@@ -52,12 +58,15 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
52
58
if err != nil {
53
59
return err
54
60
}
61
+ log .Println ("Done running packages.Load." )
55
62
56
63
if len (pkgs ) == 0 {
57
- log .Printf ("No packages found." )
64
+ log .Println ("No packages found." )
58
65
}
59
66
67
+ log .Println ("Extracting universe scope." )
60
68
extractUniverseScope ()
69
+ log .Println ("Done extracting universe scope." )
61
70
62
71
// a map of package path to package root directory (currently the module root or the source directory)
63
72
pkgRoots := make (map [string ]string )
@@ -72,6 +81,8 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
72
81
packages .Visit (pkgs , func (pkg * packages.Package ) bool {
73
82
return true
74
83
}, func (pkg * packages.Package ) {
84
+ log .Printf ("Processing package %s." , pkg .PkgPath )
85
+
75
86
if _ , ok := pkgRoots [pkg .PkgPath ]; ! ok {
76
87
mdir := util .GetModDir (pkg .PkgPath , modFlags ... )
77
88
pdir := util .GetPkgDir (pkg .PkgPath , modFlags ... )
@@ -84,6 +95,8 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
84
95
pkgDirs [pkg .PkgPath ] = pdir
85
96
}
86
97
98
+ log .Printf ("Extracting types for package %s." , pkg .PkgPath )
99
+
87
100
tw , err := trap .NewWriter (pkg .PkgPath , pkg )
88
101
if err != nil {
89
102
log .Fatal (err )
@@ -102,6 +115,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
102
115
extractError (tw , err , lbl , i )
103
116
}
104
117
}
118
+ log .Printf ("Done extracting types for package %s." , pkg .PkgPath )
105
119
})
106
120
107
121
for _ , pkg := range pkgs {
@@ -111,6 +125,10 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
111
125
wantedRoots [pkgRoots [pkg.PkgPath ]] = true
112
126
}
113
127
128
+ log .Println ("Done processing dependencies." )
129
+
130
+ log .Println ("Starting to extract packages." )
131
+
114
132
// this sets the number of threads that the Go runtime will spawn; this is separate
115
133
// from the number of goroutines that the program spawns, which are scheduled into
116
134
// the system threads by the Go runtime scheduler
@@ -163,10 +181,15 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
163
181
extractPackage (pkg , & wg , goroutineSem , fdSem )
164
182
return
165
183
}
184
+
185
+ log .Printf ("Skipping dependency package %s." , pkg .PkgPath )
166
186
})
167
187
168
188
wg .Wait ()
169
189
190
+ log .Println ("Done extracting packages." )
191
+ log .Println ("Starting to extract go.mod files." )
192
+
170
193
cwd , err := os .Getwd ()
171
194
if err != nil {
172
195
log .Printf ("Warning: unable to get working directory: %s" , err .Error ())
@@ -204,6 +227,8 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
204
227
log .Printf ("Done extracting %s (%dms)" , path , end .Nanoseconds ()/ 1000000 )
205
228
}
206
229
230
+ log .Println ("Done extracting go.mod files." )
231
+
207
232
return nil
208
233
}
209
234
0 commit comments