blob: 843d8693298ab417827240b69de49616f2c4438b (
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
37
38
39
40
41
42
43
44
45
46
|
package forgepb
import (
"os"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
// set FORGE_GOSRC env if not already set
func init() {
gosrc := os.Getenv("FORGE_GOSRC")
if gosrc != "" {
// already set. ignore init()
}
goSrcDir, err := FindGoSrc()
if err != nil {
log.Warn("forge init() FindGoSrc()", err)
panic("forge init() FindGoSrc()")
}
os.Setenv("FORGE_GOSRC", goSrcDir)
}
func Init() *Forge {
f := new(Forge)
f.Config = new(ForgeConfigs)
// load the ~/.config/forge/ config
if err := f.Config.ConfigLoad(); err != nil {
log.Warn("forgepb.ConfigLoad() failed", err)
os.Exit(-1)
}
if f.Repos == nil {
f.Repos = new(gitpb.Repos)
}
f.goSrc = os.Getenv("FORGE_GOSRC")
f.ScanGoSrc()
log.Warn("GOT HERE. forge.Init(). f can not be nil")
return f
}
func (f *Forge) SortByPath() *ForgeConfigIterator {
return f.Config.SortByPath()
}
|