From 9873bc3d57b89f1e3b142001660a9a4ac2e18810 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 13 Dec 2024 02:22:13 -0600 Subject: clean up Init() --- init.go | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'init.go') diff --git a/init.go b/init.go index ca40f25..6b7c420 100644 --- a/init.go +++ b/init.go @@ -9,6 +9,9 @@ import ( "go.wit.com/log" ) +// todo: use initOnce +// cache.go has Do() +// f.initOnce.Do(f.initWork) func Init() *Forge { f := new(Forge) @@ -37,37 +40,38 @@ func Init() *Forge { } // print out the settings that will be used - log.Info("forgepbb.Init() FORGE_CONFIG", os.Getenv("FORGE_CONFIG")) - log.Info("forgepbb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "f.goWork =", f.IsGoWork()) - - // cache.go has Do() - // f.initOnce.Do(f.initWork) - - f.Config = new(ForgeConfigs) + log.Info("forgepb.Init() FORGE_CONFIG", os.Getenv("FORGE_CONFIG")) // load the ~/.config/forge/ config + f.Config = new(ForgeConfigs) if err := f.Config.ConfigLoad(); err != nil { log.Warn("forgepb.ConfigLoad() failed", err) os.Exit(-1) } + if f.IsGoWork() { + log.Info("forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = true)") + } else { + log.Info("forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = false)") + } f.Repos = new(gitpb.Repos) f.Repos.ConfigLoad() - f.Machine = new(zoopb.Machine) - - if err := f.Machine.ConfigLoad(); err != nil { - log.Warn("zoopb.ConfigLoad() failed", err) - os.Exit(-1) - } - f.Machine.InitWit() start := f.Repos.Len() f.ScanGoSrc() end := f.Repos.Len() if (end - start) == 0 { - log.Info("Scan of", f.GetGoSrc(), "did not find new git repositories") + log.Info("forgepb.Scan() Scan did not find new git repositories.") } else { - log.Info("Scan of", f.GetGoSrc(), "Found", end-start, "new git repositories") + log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.") + } + + f.Machine = new(zoopb.Machine) + + if err := f.Machine.ConfigLoad(); err != nil { + log.Warn("zoopb.ConfigLoad() failed", err) + os.Exit(-1) } + f.Machine.InitWit() return f } -- cgit v1.2.3