sort go.work file

This commit is contained in:
Jeff Carr 2024-03-09 16:49:57 -06:00
parent 4dbfd68272
commit 06904e1158
1 changed files with 13 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"sort"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/repostatus"
@ -191,7 +192,16 @@ func (rl *RepoList) MakeGoWork() error {
fmt.Fprintln(f, "go 1.21.4") // fix this fmt.Fprintln(f, "go 1.21.4") // fix this
fmt.Fprintln(f, "") fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (") fmt.Fprintln(f, "use (")
for _, repo := range rl.allrepos {
keys := make([]string, 0, len(rl.allrepos))
for k := range rl.allrepos {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
repo := rl.allrepos[k]
if repo.Status.GoPath() == "" { if repo.Status.GoPath() == "" {
// skip repos that aren't go // skip repos that aren't go
// todo: handle non-flat repos? // todo: handle non-flat repos?
@ -200,8 +210,8 @@ func (rl *RepoList) MakeGoWork() error {
if repo.Status.Exists("go.mod") { if repo.Status.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.Status.GoPath()) fmt.Fprintln(f, "\t"+repo.Status.GoPath())
} else { } else {
log.Info("missing go.mod for", repo.Status.Path()) log.Log(REPO, "missing go.mod for", repo.Status.Path())
repo.Status.MakeRedomod() // repo.Status.MakeRedomod()
} }
} }
fmt.Fprintln(f, ")") fmt.Fprintln(f, ")")