summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'init.go')
-rw-r--r--init.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/init.go b/init.go
index 8c6af82..f22d30d 100644
--- a/init.go
+++ b/init.go
@@ -2,8 +2,8 @@ package forgepb
import (
"os"
- "path/filepath"
+ "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -13,13 +13,12 @@ func init() {
if gosrc != "" {
// already set. ignore init()
}
- homeDir, err := os.UserHomeDir()
+ goSrcDir, err := FindGoSrc()
if err != nil {
- log.Warn("forge init() could not find UserHomeDir()", err)
- panic("forge could not find UserHomeDir")
+ log.Warn("forge init() FindGoSrc()", err)
+ panic("forge init() FindGoSrc()")
}
- fullpath := filepath.Join(homeDir, "go/src")
- os.Setenv("FORGE_GOSRC", fullpath)
+ os.Setenv("FORGE_GOSRC", goSrcDir)
}
func (f *Forge) Init() {
@@ -34,6 +33,13 @@ func (f *Forge) Init() {
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()
}
func (f *Forge) SortByPath() *ForgeConfigIterator {