summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-01 22:23:02 -0600
committerJeff Carr <[email protected]>2024-12-01 22:23:02 -0600
commitdc3fe4bd2e4fff95bd938eada5d71314e124b2c1 (patch)
treed408a2f802b18731379a95fa06d5ba372525836b /init.go
parent9439051fc699d2ce5becc6cc88137d7e689ad95b (diff)
auto run autogenpb on Build()
Diffstat (limited to 'init.go')
-rw-r--r--init.go26
1 files changed, 12 insertions, 14 deletions
diff --git a/init.go b/init.go
index b8b8498..1a8384b 100644
--- a/init.go
+++ b/init.go
@@ -8,22 +8,21 @@ import (
"go.wit.com/log"
)
-// set FORGE_GOSRC env if not already set
-func init() {
+func Init() *Forge {
+ f := new(Forge)
+
+ // TODO: rethink this but it works for now
gosrc := os.Getenv("FORGE_GOSRC")
- if gosrc != "" {
+ if gosrc == "" {
// already set. ignore init()
+ goSrcDir, err := f.findGoSrc()
+ if err != nil {
+ log.Warn("forge init() findGoSrc()", err)
+ panic("forge init() findGoSrc()")
+ }
+ os.Setenv("FORGE_GOSRC", goSrcDir)
}
- 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.goSrc = os.Getenv("FORGE_GOSRC")
// cache.go has Do()
// f.initOnce.Do(f.initWork)
@@ -46,7 +45,6 @@ func Init() *Forge {
}
f.Machine.InitWit()
- f.goSrc = os.Getenv("FORGE_GOSRC")
f.ScanGoSrc()
log.Info("forge.Init() found", f.Repos.Len(), "repos in", f.goSrc)
return f