fix: empty module
ci/woodpecker/push/goreleaser Pipeline was successful Details

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main v0.0.8
jolheiser 2023-07-16 22:56:33 -05:00
parent 49a668d1a9
commit 587759243a
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
2 changed files with 6 additions and 14 deletions

5
imp.go
View File

@ -16,10 +16,7 @@ import (
)
func runImp(root, ignore string, write, gofumpt, gofumptExtra bool) error {
mod, err := modInfo(root)
if err != nil {
return err
}
mod := modInfo(root)
globs, err := globber.ParseFile(ignore)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {

15
main.go
View File

@ -38,10 +38,7 @@ func mainErr() error {
}
if *stdinFlag {
mod, err := modInfo(cwd)
if err != nil {
return err
}
mod := modInfo(cwd)
src, err := io.ReadAll(os.Stdin)
if err != nil {
return err
@ -85,17 +82,15 @@ func (m *module) UnmarshalJSON(data []byte) error {
return nil
}
func modInfo(dir string) (module, error) {
func modInfo(dir string) module {
cmd := exec.Command("go", "mod", "edit", "--json")
cmd.Dir = dir
out, err := cmd.Output()
if err != nil {
return module{}, err
return module{}
}
var m module
if err := json.Unmarshal(out, &m); err != nil {
return m, err
}
return m, nil
_ = json.Unmarshal(out, &m)
return m
}