From 587759243ae7bff1a0dd657d68a807488f05aae0 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sun, 16 Jul 2023 22:56:33 -0500 Subject: [PATCH] fix: empty module Signed-off-by: jolheiser --- imp.go | 5 +---- main.go | 15 +++++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/imp.go b/imp.go index 672efd7..e2e260c 100644 --- a/imp.go +++ b/imp.go @@ -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) { diff --git a/main.go b/main.go index b2f6e20..c8ec462 100644 --- a/main.go +++ b/main.go @@ -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 }