// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 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.Config.ReposDir, "go.work") workf, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { return err } defer workf.Close() fmt.Fprintln(workf, "go 1.21") // fix this fmt.Fprintln(workf, "") fmt.Fprintln(workf, "use (") all := f.Repos.SortByFullPath() for all.Scan() { repo := all.Next() if repo.GetGoPath() == "" { continue } fmt.Fprintln(workf, "\t"+repo.GetGoPath()) } fmt.Fprintln(workf, ")") return nil }