@@ -32,6 +32,12 @@ func Extract(patterns []string) error {
3232
3333// ExtractWithFlags extracts the packages specified by the given patterns and build flags
3434func 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." )
3541 cfg := & packages.Config {
3642 Mode : packages .NeedName | packages .NeedFiles |
3743 packages .NeedCompiledGoFiles |
@@ -52,12 +58,15 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
5258 if err != nil {
5359 return err
5460 }
61+ log .Println ("Done running packages.Load." )
5562
5663 if len (pkgs ) == 0 {
57- log .Printf ("No packages found." )
64+ log .Println ("No packages found." )
5865 }
5966
67+ log .Println ("Extracting universe scope." )
6068 extractUniverseScope ()
69+ log .Println ("Done extracting universe scope." )
6170
6271 // a map of package path to package root directory (currently the module root or the source directory)
6372 pkgRoots := make (map [string ]string )
@@ -72,6 +81,8 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
7281 packages .Visit (pkgs , func (pkg * packages.Package ) bool {
7382 return true
7483 }, func (pkg * packages.Package ) {
84+ log .Printf ("Processing package %s." , pkg .PkgPath )
85+
7586 if _ , ok := pkgRoots [pkg .PkgPath ]; ! ok {
7687 mdir := util .GetModDir (pkg .PkgPath , modFlags ... )
7788 pdir := util .GetPkgDir (pkg .PkgPath , modFlags ... )
@@ -84,6 +95,8 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
8495 pkgDirs [pkg .PkgPath ] = pdir
8596 }
8697
98+ log .Printf ("Extracting types for package %s." , pkg .PkgPath )
99+
87100 tw , err := trap .NewWriter (pkg .PkgPath , pkg )
88101 if err != nil {
89102 log .Fatal (err )
@@ -102,6 +115,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
102115 extractError (tw , err , lbl , i )
103116 }
104117 }
118+ log .Printf ("Done extracting types for package %s." , pkg .PkgPath )
105119 })
106120
107121 for _ , pkg := range pkgs {
@@ -111,6 +125,10 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
111125 wantedRoots [pkgRoots [pkg.PkgPath ]] = true
112126 }
113127
128+ log .Println ("Done processing dependencies." )
129+
130+ log .Println ("Starting to extract packages." )
131+
114132 // this sets the number of threads that the Go runtime will spawn; this is separate
115133 // from the number of goroutines that the program spawns, which are scheduled into
116134 // the system threads by the Go runtime scheduler
@@ -163,10 +181,15 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
163181 extractPackage (pkg , & wg , goroutineSem , fdSem )
164182 return
165183 }
184+
185+ log .Printf ("Skipping dependency package %s." , pkg .PkgPath )
166186 })
167187
168188 wg .Wait ()
169189
190+ log .Println ("Done extracting packages." )
191+ log .Println ("Starting to extract go.mod files." )
192+
170193 cwd , err := os .Getwd ()
171194 if err != nil {
172195 log .Printf ("Warning: unable to get working directory: %s" , err .Error ())
@@ -204,6 +227,8 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
204227 log .Printf ("Done extracting %s (%dms)" , path , end .Nanoseconds ()/ 1000000 )
205228 }
206229
230+ log .Println ("Done extracting go.mod files." )
231+
207232 return nil
208233}
209234
0 commit comments