2020-07-20 10:52:58 +00:00
|
|
|
package main // import "github.com/tweag/gomod2nix"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
type packageJob struct {
|
2020-07-20 11:29:04 +00:00
|
|
|
importPath string
|
2020-07-20 10:52:58 +00:00
|
|
|
goPackagePath string
|
|
|
|
rev string
|
|
|
|
}
|
|
|
|
|
|
|
|
type packageResult struct {
|
|
|
|
pkg *Package
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func worker(id int, replace map[string]string, jobs <-chan *packageJob, results chan<- *packageResult) {
|
|
|
|
for j := range jobs {
|
2020-07-20 11:29:04 +00:00
|
|
|
pkg, err := fetchPackage(j.importPath, j.goPackagePath, j.rev)
|
2020-07-20 10:52:58 +00:00
|
|
|
results <- &packageResult{
|
|
|
|
err: err,
|
|
|
|
pkg: pkg,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
2020-07-20 11:29:04 +00:00
|
|
|
numWorkers := 20
|
|
|
|
keepGoing := true
|
2020-07-20 10:52:58 +00:00
|
|
|
directory := "./"
|
|
|
|
|
2020-07-20 11:29:04 +00:00
|
|
|
pkgs, err := FetchPackages(filepath.Join(directory, "go.mod"), filepath.Join(directory, "go.sum"), numWorkers, keepGoing)
|
2020-07-20 10:52:58 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2020-07-20 11:29:04 +00:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
fmt.Println(pkg)
|
2020-07-20 10:52:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|