diff options
| author | Jeff Carr <[email protected]> | 2024-12-07 16:50:04 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-07 16:50:04 -0600 |
| commit | c08079fc2fba6d5dd65bc878e51dc59680f2de5e (patch) | |
| tree | 368d54529d4970afcdeafe12de74d165edb2fa08 /goWork.go | |
| parent | 7f1f8d4028fada967beb484e30a336dfa30e6806 (diff) | |
deubgging auto go buildv0.0.27
Diffstat (limited to 'goWork.go')
| -rw-r--r-- | goWork.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/goWork.go b/goWork.go new file mode 100644 index 0000000..c709781 --- /dev/null +++ b/goWork.go @@ -0,0 +1,53 @@ +package forgepb + +import ( + "errors" + "fmt" + "os" + "path/filepath" +) + +// very much a hack job +func (f *Forge) MakeGoWork() error { + if f.IsGoWork() { + // a go.work file was found + } else { + // you can use a go.work file in ~/go/src , but you probably shouldn't unless something + // has gone terribly wrong + return errors.New("if you want a go.work file in ~/go/src/, touch it first") + } + filename := filepath.Join(f.GetGoSrc(), "go.work") + workf, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600) + if err != nil { + return err + } + defer workf.Close() + + fmt.Fprintln(workf, "go 1.20") // fix this + fmt.Fprintln(workf, "") + fmt.Fprintln(workf, "use (") + + loop := f.Repos.SortByGoPath() + for loop.Scan() { + repo := loop.Next() + /* + if !repo.IsGoLang() == "" { + // skip repos that aren't go + // todo: handle non-flat repos? + log.Info("skip non-go", repo.GoPath) + continue + } + */ + fmt.Fprintln(workf, "\t"+repo.GoPath) + /* + if repo.pb.Exists("go.mod") { + // log.Info("ADDING REPO", goSrcDir, repo.GoPath) + } else { + fmt.Fprintln(workf, "\t"+repo.GoPath) + log.Log(REPO, "missing go.mod for", repo.GoPath) + } + */ + } + fmt.Fprintln(workf, ")") + return nil +} |
