From f09d0fbfa9a9ffb037943fecdab13f0e53212850 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 9 Mar 2024 22:00:10 -0600 Subject: [PATCH] run 'go work use' at the end --- argv.go | 4 ++-- main.go | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/argv.go b/argv.go index 4a8cbf9..2d22dc7 100644 --- a/argv.go +++ b/argv.go @@ -7,8 +7,8 @@ package main */ type args struct { - Repo string `arg:"positional" help:"go import path"` - Work bool `arg:"--work" help:"make a work directory"` + Repo string `arg:"positional" help:"go import path"` + Work bool `arg:"--work" help:"make a work directory"` NoWork bool `arg:"--no-work" help:"does not make a go.work file"` } diff --git a/main.go b/main.go index e9b48cb..6f15a74 100644 --- a/main.go +++ b/main.go @@ -62,16 +62,31 @@ func main() { godep := newr.Status.GetGoDeps() for gopath, version := range godep { - if _, err := rv.NewRepo(gopath); err != nil { + repo, err := rv.NewRepo(gopath) + if err != nil { log.Info("git clone failed for", gopath, version) + continue + } + repo.Status.MakeRedomod() + } + + for _, repo := range rv.AllRepos() { + if ! repo.Status.Exists("go.mod") { + repo.Status.MakeRedomod() } } log.Info("all repositories are cloned") - if ! myargs.NoWork { - log.Info("Creating", wdir + "/go.work") + if !myargs.NoWork { + log.Info("Creating", wdir+"/go.work") rv.MakeGoWork() + shell.RunPath(wdir, []string{"go", "work", "use"}) } + + for _, repo := range rv.AllRepos() { + log.Info("found repo", repo.GoPath(), repo.Status.Path()) + } + } // look for or make a go.work file