From de1d135e0920d07506d3a1f956f9a7d47546997a Mon Sep 17 00:00:00 2001 From: Sam Teeter Date: Thu, 30 Sep 2021 13:44:31 -0500 Subject: [PATCH] Fall back to path mode when no go.mod is present Following this change, if godef cannot find a go.mod file for the current module (that is, if the go env command returns the null device for gomod), then godef will default to non-module mode rather than failing. --- adapt.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapt.go b/adapt.go index d24e1ea..ad0455e 100644 --- a/adapt.go +++ b/adapt.go @@ -94,7 +94,8 @@ func detectModuleMode(cfg *packages.Config) bool { cmd.Dir = cfg.Dir out, err := cmd.Output() if err == nil { - return len(strings.TrimSpace(string(out))) > 0 + outstr := strings.TrimSpace(string(out)) + return len(outstr) > 0 && outstr != os.DevNull } // default to non module mode return false