From 3b90d979d73da9896570d2dc927e05e769b9670b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 28 Nov 2024 21:04:10 -0600 Subject: [PATCH] init things from here --- godep.redoGoMod.go | 15 +++++++++++++++ scanGoSrc/argv.go | 2 +- shell.go | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/godep.redoGoMod.go b/godep.redoGoMod.go index 2ce7676..79a86f7 100644 --- a/godep.redoGoMod.go +++ b/godep.redoGoMod.go @@ -115,3 +115,18 @@ func (repo *Repo) parseGoSum() (bool, error) { } return true, nil } +func (repo *Repo) RepoType() string { + os.Setenv("GO111MODULE", "off") + cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"} + // cmd := []string{"go", "list", "-f", "'{{.Name}}'"} // probably use this. this just prints out the package name + // cmd := []string{"go", "list", "-f", "'{{.ImportPath}}'"} // returns go.wit.com/lib/protobuf/gitpb + + result := repo.RunQuiet(cmd) + if result.Error != nil { + log.Warn("go list binary detect failed", result.Error) + return "" + } + output := strings.TrimSpace(strings.Join(result.Stdout, "\n")) + output = strings.Trim(output, "'") + return output +} diff --git a/scanGoSrc/argv.go b/scanGoSrc/argv.go index 5e01d4f..635989f 100644 --- a/scanGoSrc/argv.go +++ b/scanGoSrc/argv.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/alexflint/go-arg" + "go.wit.com/dev/alexflint/arg" ) var argv args diff --git a/shell.go b/shell.go index de82f84..e7ed273 100644 --- a/shell.go +++ b/shell.go @@ -23,6 +23,17 @@ func (repo *Repo) Run(cmd []string) cmd.Status { return result } +func (repo *Repo) RunQuiet(cmd []string) cmd.Status { + result := shell.PathRunQuiet(repo.FullPath, cmd) + output := strings.Join(result.Stdout, "\n") + if result.Error != nil { + log.Warn("cmd:", cmd) + log.Warn("ouptput:", output) + log.Warn("failed with error:", result.Error) + } + return result +} + // for now, even check cmd.Exit func (repo *Repo) strictRun(cmd []string) (bool, error) { result := repo.Run(cmd)