From 6fa3221e265933038342acb50caad3c2bbb6c136 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Nov 2025 12:15:41 -0500 Subject: test making go.work files --- goWork.go | 12 +++--------- init.go | 1 + load.go | 6 ++++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/goWork.go b/goWork.go index 0c8fe4e..d947df7 100644 --- a/goWork.go +++ b/goWork.go @@ -3,22 +3,16 @@ package forgepb import ( - "errors" "fmt" "os" "path/filepath" + + "go.wit.com/lib/env" ) // very much a hack job func (f *Forge) MakeGoWork() error { - if f.IsGoWork() { - // a go.work file was found - } else { - // you can use a go.work file in ~/go/src , but you probably shouldn't unless something - // has gone terribly wrong - return errors.New("if you want a go.work file in ~/go/src/, touch it first") - } - filename := filepath.Join(getClonePathFromMode(), "go.work") + 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 diff --git a/init.go b/init.go index 6962c67..26daa49 100644 --- a/init.go +++ b/init.go @@ -76,6 +76,7 @@ func (f *Forge) postInit() error { if godir, ok := fhelp.FindGoWork(); ok { f.mode = ForgeMode_GOLANG cache = "gowork" + env.SetGlobal("lib/forgepb", "GoWork", "true") env.SetGlobal("lib/forgepb", "gopath", godir) fullname := filepath.Join(godir, "gowork.pb") env.SetGlobal("lib/forgepb", "ReposPB", fullname) diff --git a/load.go b/load.go index 283921d..38790bd 100644 --- a/load.go +++ b/load.go @@ -74,9 +74,11 @@ func (f *Forge) reposCacheLoad() error { reposName = "homedir" } - // get the + // load in the repos.pb file + // setup the GO env settings fullname := config.MakeCacheFilename("forge", reposName) - if env.Get("cache") == "gowork" { + if env.True("GoWork") { + // if using a go.work file, the filename should have already been set fullname = env.Get("ReposPB") } f.Repos = gitpb.NewRepos() -- cgit v1.2.3