pull down missing go deps

This commit is contained in:
Jeff Carr 2024-03-09 09:23:41 -06:00
parent a048e33f58
commit 4dbfd68272
1 changed files with 35 additions and 0 deletions

View File

@ -1,6 +1,10 @@
package repolist
import (
"fmt"
"os"
"path/filepath"
"go.wit.com/gui"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
@ -172,3 +176,34 @@ func (rl *RepoList) TotalGo() int {
}
return count
}
// very much a hack job
func (rl *RepoList) MakeGoWork() error {
goSrcDir := os.Getenv("REPO_WORK_PATH")
filename := filepath.Join(goSrcDir, "go.work")
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return err
}
defer f.Close()
fmt.Fprintln(f, "go 1.21.4") // fix this
fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (")
for _, repo := range rl.allrepos {
if repo.Status.GoPath() == "" {
// skip repos that aren't go
// todo: handle non-flat repos?
continue
}
if repo.Status.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.Status.GoPath())
} else {
log.Info("missing go.mod for", repo.Status.Path())
repo.Status.MakeRedomod()
}
}
fmt.Fprintln(f, ")")
return nil
}