blob: d947df7ac91f7751970ff4a77f12f50648310f07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
package forgepb
import (
"fmt"
"os"
"path/filepath"
"go.wit.com/lib/env"
)
// very much a hack job
func (f *Forge) MakeGoWork() error {
filename := filepath.Join(env.Get("gopath"), "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
}
|