@@ -221,6 +221,22 @@ func checkVendor() bool {
221
221
return true
222
222
}
223
223
224
+ func getDepMode () DependencyInstallerMode {
225
+ if util .FileExists ("go.mod" ) {
226
+ log .Println ("Found go.mod, enabling go modules" )
227
+ return GoGetWithModules
228
+ }
229
+ if util .FileExists ("Gopkg.toml" ) {
230
+ log .Println ("Found Gopkg.toml, using dep instead of go get" )
231
+ return Dep
232
+ }
233
+ if util .FileExists ("glide.yaml" ) {
234
+ log .Println ("Found glide.yaml, enabling go modules" )
235
+ return Glide
236
+ }
237
+ return GoGetNoModules
238
+ }
239
+
224
240
func main () {
225
241
if len (os .Args ) > 1 {
226
242
usage ()
@@ -247,15 +263,14 @@ func main() {
247
263
248
264
// determine how to install dependencies and whether a GOPATH needs to be set up before
249
265
// extraction
250
- depMode := GoGetNoModules
266
+ depMode := getDepMode ()
251
267
modMode := ModUnset
252
268
needGopath := true
253
269
goDirectiveFound := false
254
270
if _ , present := os .LookupEnv ("GO111MODULE" ); ! present {
255
271
os .Setenv ("GO111MODULE" , "auto" )
256
272
}
257
- if util .FileExists ("go.mod" ) {
258
- depMode = GoGetWithModules
273
+ if depMode == GoGetWithModules {
259
274
needGopath = false
260
275
versionRe := regexp .MustCompile (`(?m)^go[ \t\r]+([0-9]+\.[0-9]+)$` )
261
276
goMod , err := ioutil .ReadFile ("go.mod" )
@@ -273,13 +288,6 @@ func main() {
273
288
}
274
289
}
275
290
}
276
- log .Println ("Found go.mod, enabling go modules" )
277
- } else if util .FileExists ("Gopkg.toml" ) {
278
- depMode = Dep
279
- log .Println ("Found Gopkg.toml, using dep instead of go get" )
280
- } else if util .FileExists ("glide.yaml" ) {
281
- depMode = Glide
282
- log .Println ("Found glide.yaml, enabling go modules" )
283
291
}
284
292
285
293
if depMode == GoGetWithModules {
0 commit comments