init things from here

This commit is contained in:
Jeff Carr 2024-11-28 21:04:10 -06:00
parent 02b9ed57b3
commit 3b90d979d7
3 changed files with 27 additions and 1 deletions

View File

@ -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
}

View File

@ -3,7 +3,7 @@ package main
import (
"os"
"github.com/alexflint/go-arg"
"go.wit.com/dev/alexflint/arg"
)
var argv args

View File

@ -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)