@@ -64,12 +64,6 @@ import (
64
64
)
65
65
66
66
var (
67
- // List of go modules for linting/testing/etc.
68
- workspaceModules = []string {
69
- "." ,
70
- "./cmd/keeper" ,
71
- }
72
-
73
67
// Files that end up in the geth*.zip archive.
74
68
gethArchiveFiles = []string {
75
69
"COPYING" ,
@@ -328,7 +322,7 @@ func doTest(cmdline []string) {
328
322
gotest .Args = append (gotest .Args , "-short" )
329
323
}
330
324
331
- packages := workspacePackagePatterns ()
325
+ packages := [] string { "work" }
332
326
if len (flag .CommandLine .Args ()) > 0 {
333
327
packages = flag .CommandLine .Args ()
334
328
}
@@ -370,7 +364,7 @@ func doCheckGenerate() {
370
364
protocPath = downloadProtoc (* cachedir )
371
365
protocGenGoPath = downloadProtocGenGo (* cachedir )
372
366
)
373
- c := tc .Go ("generate" , workspacePackagePatterns () ... )
367
+ c := tc .Go ("generate" , "work" )
374
368
pathList := []string {filepath .Join (protocPath , "bin" ), protocGenGoPath , os .Getenv ("PATH" )}
375
369
c .Env = append (c .Env , "PATH=" + strings .Join (pathList , string (os .PathListSeparator )))
376
370
build .MustRun (c )
@@ -428,11 +422,31 @@ func doCheckBadDeps() {
428
422
func doLint (cmdline []string ) {
429
423
var (
430
424
cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching golangci-lint binary." )
425
+ tc = new (build.GoToolchain )
431
426
)
432
427
flag .CommandLine .Parse (cmdline )
433
- packages := workspacePackagePatterns ()
434
- if len (flag .CommandLine .Args ()) > 0 {
435
- packages = flag .CommandLine .Args ()
428
+
429
+ packages := flag .CommandLine .Args ()
430
+ if len (packages ) == 0 {
431
+ // Get module directories in workspace.
432
+ listing , err := tc .Go ("list" , "-m" ).Output ()
433
+ if err != nil {
434
+ log .Fatalf ("go list failed:" , err )
435
+ }
436
+ var mainModule []byte
437
+ for i , m := range bytes .Split (listing , []byte ("\n " )) {
438
+ m = bytes .TrimSpace (m )
439
+ if i == 0 {
440
+ mainModule = m
441
+ packages = append (packages , "./..." )
442
+ } else if len (m ) > 0 {
443
+ dir := string (bytes .TrimPrefix (m , mainModule ))
444
+ packages = append (packages , "." + dir + "/..." )
445
+ }
446
+ }
447
+ if len (packages ) == 0 {
448
+ log .Fatal ("no packages found" )
449
+ }
436
450
}
437
451
438
452
linter := downloadLinter (* cachedir )
@@ -1175,11 +1189,3 @@ func doSanityCheck() {
1175
1189
csdb := download .MustLoadChecksums ("build/checksums.txt" )
1176
1190
csdb .DownloadAndVerifyAll ()
1177
1191
}
1178
-
1179
- func workspacePackagePatterns () []string {
1180
- p := make ([]string , len (workspaceModules ))
1181
- for i := range workspaceModules {
1182
- p [i ] = workspaceModules [i ] + "/..."
1183
- }
1184
- return p
1185
- }
0 commit comments