diff options
| author | Jeff Carr <[email protected]> | 2025-09-13 08:31:54 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-13 08:31:54 -0500 |
| commit | cb6394f34a250aed6cb186bd2a9af39d8c19f5f4 (patch) | |
| tree | 37eadbb71aea7b121760062f14a0938e44e921f4 /goSrcFind.go | |
| parent | 2fccf603358f5c7e3f3403c1ca5e7f50451d88fd (diff) | |
finally dump this old code
Diffstat (limited to 'goSrcFind.go')
| -rw-r--r-- | goSrcFind.go | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/goSrcFind.go b/goSrcFind.go deleted file mode 100644 index cef82bb..0000000 --- a/goSrcFind.go +++ /dev/null @@ -1,86 +0,0 @@ -package forgepb - -// returns whatever your golang source dir is -// If there is a go.work file in your parent, that directory will be returned -// otherwise, return ~/go/src - -func (f *Forge) GetHome() string { - return f.Config.ReposDir -} - -/* -// look for a go.work file -// otherwise use ~/go/src -func (f *Forge) findGoSrc() (string, error) { - pwd, err := os.Getwd() - // startpwd, _ := os.Getwd() - if err == nil { - // Check for go.work in the current directory and then move up until root - if pwd, err := digup(pwd); err == nil { - f.goWork = true - // found an existing go.work file - // os.Chdir(pwd) - return pwd, nil - } else { - // if there is an error looking for the go.work file - // default to using ~/go/src - // log.Info("forge.digup() err", pwd, err) - } - } else { - // this shouldn't really happen. maybe your working directory got deleted - log.Info("forge.findGoSrc() os.Getwd() was probably deleted", pwd, err) - } - - // there are no go.work files, resume the ~/go/src behavior from prior to golang 1.22 - pwd, err = useGoSrc() - return pwd, err -} - -// this is the 'old way" and works fine for me. I use it because I like the ~/go/src directory -// because I know exactly what is in it: GO stuff & nothing else -func useGoSrc() (string, error) { - homeDir, err := os.UserHomeDir() - if err != nil { - return "", err - } - pwd := filepath.Join(homeDir, "go/src") - err = os.MkdirAll(pwd, os.ModePerm) - return pwd, err -} - -func (f *Forge) goWorkExists() bool { - var err error - workFilePath := filepath.Join(f.Config.ReposDir, "go.work") - if _, err = os.Stat(workFilePath); err == nil { - // log.Info("f.goWorkExists() found", workFilePath) - return true - } else if !os.IsNotExist(err) { - // log.Info("f.goWorkExists() missing", workFilePath) - return false - } - // probably false, but some other error - // log.Info("f.goWorkExists() os.Stat() error", err, workFilePath) - return false -} -*/ - -/* -func digup(path string) (string, error) { - for { - workFilePath := filepath.Join(path, "go.work") - if _, err := os.Stat(workFilePath); err == nil { - return path, nil // Found the go.work file - } else if !os.IsNotExist(err) { - return "", err // An error other than not existing - } - - parentPath := filepath.Dir(path) - if parentPath == path { - break // Reached the filesystem root - } - path = parentPath - } - - return "", fmt.Errorf("no go.work file found") -} -*/ |
