gomod2nix/main.go
2020-10-29 13:26:16 +01:00

39 lines
782 B
Go

package main // import "github.com/tweag/gomod2nix"
import (
"flag"
"fmt"
"github.com/tweag/gomod2nix/fetch"
// "github.com/tweag/gomod2nix/formats/buildgopackage"
"github.com/tweag/gomod2nix/formats/gomod2nix"
"io/ioutil"
"path/filepath"
)
func main() {
flag.Parse()
numWorkers := 20
keepGoing := true
directory := "./"
outFile := "gomod2nix.toml"
pkgs, err := fetch.FetchPackages(filepath.Join(directory, "go.mod"), filepath.Join(directory, "go.sum"), numWorkers, keepGoing)
if err != nil {
panic(err)
}
// output, err := buildgopackage.Marshal(pkgs)
output, err := gomod2nix.Marshal(pkgs)
if err != nil {
panic(err)
}
err = ioutil.WriteFile(outFile, output, 0644)
if err != nil {
panic(err)
}
fmt.Println(fmt.Sprintf("Wrote: %s", outFile))
}