gomod2nix/main.go

49 lines
952 B
Go
Raw Normal View History

2020-07-20 10:52:58 +00:00
package main // import "github.com/tweag/gomod2nix"
import (
"flag"
"fmt"
2020-07-20 11:38:32 +00:00
"github.com/tweag/gomod2nix/fetch"
2020-07-20 12:26:57 +00:00
// "github.com/tweag/gomod2nix/formats/buildgopackage"
"github.com/tweag/gomod2nix/formats/gomod2nix"
2020-07-20 12:32:17 +00:00
"io/ioutil"
2020-07-20 10:52:58 +00:00
"path/filepath"
)
func main() {
flag.Parse()
numWorkers := 1
keepGoing := false
// directory := "./"
directory := "./testdata/vuls"
2020-07-20 12:32:17 +00:00
outFile := "gomod2nix.toml"
2020-07-20 10:52:58 +00:00
goModPath := filepath.Join(directory, "go.mod")
goSumPath := filepath.Join(directory, "go.sum")
goMod2NixPath := "./gomod2nix.toml"
pkgs, err := fetch.FetchPackages(goModPath, goSumPath, goMod2NixPath, numWorkers, keepGoing)
2020-07-20 10:52:58 +00:00
if err != nil {
panic(err)
}
if true {
panic("Success")
}
2020-07-20 12:26:57 +00:00
// output, err := buildgopackage.Marshal(pkgs)
output, err := gomod2nix.Marshal(pkgs)
if err != nil {
panic(err)
2020-07-20 10:52:58 +00:00
}
2020-07-20 12:32:17 +00:00
err = ioutil.WriteFile(outFile, output, 0644)
if err != nil {
panic(err)
}
fmt.Println(fmt.Sprintf("Wrote: %s", outFile))
2020-07-20 10:52:58 +00:00
}