@@ -64,12 +64,6 @@ import (
6464)
6565
6666var (
67- // List of go modules for linting/testing/etc.
68- workspaceModules = []string {
69- "." ,
70- "./cmd/keeper" ,
71- }
72-
7367 // Files that end up in the geth*.zip archive.
7468 gethArchiveFiles = []string {
7569 "COPYING" ,
@@ -328,7 +322,7 @@ func doTest(cmdline []string) {
328322 gotest .Args = append (gotest .Args , "-short" )
329323 }
330324
331- packages := workspacePackagePatterns ()
325+ packages := [] string { "work" }
332326 if len (flag .CommandLine .Args ()) > 0 {
333327 packages = flag .CommandLine .Args ()
334328 }
@@ -370,7 +364,7 @@ func doCheckGenerate() {
370364 protocPath = downloadProtoc (* cachedir )
371365 protocGenGoPath = downloadProtocGenGo (* cachedir )
372366 )
373- c := tc .Go ("generate" , workspacePackagePatterns () ... )
367+ c := tc .Go ("generate" , "work" )
374368 pathList := []string {filepath .Join (protocPath , "bin" ), protocGenGoPath , os .Getenv ("PATH" )}
375369 c .Env = append (c .Env , "PATH=" + strings .Join (pathList , string (os .PathListSeparator )))
376370 build .MustRun (c )
@@ -428,11 +422,31 @@ func doCheckBadDeps() {
428422func doLint (cmdline []string ) {
429423 var (
430424 cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching golangci-lint binary." )
425+ tc = new (build.GoToolchain )
431426 )
432427 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+ }
436450 }
437451
438452 linter := downloadLinter (* cachedir )
@@ -1175,11 +1189,3 @@ func doSanityCheck() {
11751189 csdb := download .MustLoadChecksums ("build/checksums.txt" )
11761190 csdb .DownloadAndVerifyAll ()
11771191}
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