run 'go work use' at the end

This commit is contained in:
Jeff Carr 2024-03-09 22:00:10 -06:00
parent daa02ea023
commit f09d0fbfa9
2 changed files with 20 additions and 5 deletions

View File

@ -7,8 +7,8 @@ package main
*/ */
type args struct { type args struct {
Repo string `arg:"positional" help:"go import path"` Repo string `arg:"positional" help:"go import path"`
Work bool `arg:"--work" help:"make a work directory"` Work bool `arg:"--work" help:"make a work directory"`
NoWork bool `arg:"--no-work" help:"does not make a go.work file"` NoWork bool `arg:"--no-work" help:"does not make a go.work file"`
} }

21
main.go
View File

@ -62,16 +62,31 @@ func main() {
godep := newr.Status.GetGoDeps() godep := newr.Status.GetGoDeps()
for gopath, version := range godep { 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) 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") log.Info("all repositories are cloned")
if ! myargs.NoWork { if !myargs.NoWork {
log.Info("Creating", wdir + "/go.work") log.Info("Creating", wdir+"/go.work")
rv.MakeGoWork() 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 // look for or make a go.work file