build: add -dlgo flag in ci.go (#21824)
This new flag downloads a known version of Go and builds with it. This is meant for environments where we can't easily upgrade the installed Go version. * .travis.yml: remove install step for PR test builders We added this step originally to avoid re-building everything for every test. go test has become much smarter in recent go releases, so we no longer need to install anything here.
This commit is contained in:
		| @@ -20,6 +20,8 @@ import ( | ||||
| 	"bytes" | ||||
| 	"flag" | ||||
| 	"fmt" | ||||
| 	"go/parser" | ||||
| 	"go/token" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"log" | ||||
| @@ -152,3 +154,28 @@ func UploadSFTP(identityFile, host, dir string, files []string) error { | ||||
| 	stdin.Close() | ||||
| 	return sftp.Wait() | ||||
| } | ||||
|  | ||||
| // FindMainPackages finds all 'main' packages in the given directory and returns their | ||||
| // package paths. | ||||
| func FindMainPackages(dir string) []string { | ||||
| 	var commands []string | ||||
| 	cmds, err := ioutil.ReadDir(dir) | ||||
| 	if err != nil { | ||||
| 		log.Fatal(err) | ||||
| 	} | ||||
| 	for _, cmd := range cmds { | ||||
| 		pkgdir := filepath.Join(dir, cmd.Name()) | ||||
| 		pkgs, err := parser.ParseDir(token.NewFileSet(), pkgdir, nil, parser.PackageClauseOnly) | ||||
| 		if err != nil { | ||||
| 			log.Fatal(err) | ||||
| 		} | ||||
| 		for name := range pkgs { | ||||
| 			if name == "main" { | ||||
| 				path := "./" + filepath.ToSlash(pkgdir) | ||||
| 				commands = append(commands, path) | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return commands | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user