diff --git a/gopls/go.mod b/gopls/go.mod index 2fa06740251..67e514aebc7 100644 --- a/gopls/go.mod +++ b/gopls/go.mod @@ -25,3 +25,5 @@ require ( golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 golang.org/x/text v0.3.7 // indirect ) + +replace golang.org/x/tools => ../ \ No newline at end of file diff --git a/gopls/internal/vulncheck/command.go b/gopls/internal/vulncheck/command.go index b9aba157068..a166fe44d64 100644 --- a/gopls/internal/vulncheck/command.go +++ b/gopls/internal/vulncheck/command.go @@ -9,6 +9,7 @@ package vulncheck import ( "context" + "fmt" "log" "os" "sort" @@ -78,8 +79,8 @@ func (c *cmd) Run(ctx context.Context, cfg *packages.Config, patterns ...string) logger.Println("loading packages...") loadedPkgs, err := gvc.LoadPackages(cfg, patterns...) if err != nil { - logger.Printf("package load failed: %v", err) - return nil, err + logger.Printf("%v", err) + return nil, fmt.Errorf("package load failed") } logger.Printf("analyzing %d packages...\n", len(loadedPkgs)) diff --git a/internal/lsp/cmd/vulncheck.go b/internal/lsp/cmd/vulncheck.go index d5b05a92427..ec1743a69d0 100644 --- a/internal/lsp/cmd/vulncheck.go +++ b/internal/lsp/cmd/vulncheck.go @@ -71,7 +71,7 @@ func (v *vulncheck) Run(ctx context.Context, args ...string) error { opts := source.DefaultOptions().Clone() v.app.options(opts) // register hook if opts == nil || opts.Hooks.Govulncheck == nil { - return tool.CommandLineErrorf("vulncheck feature is not available") + return fmt.Errorf("vulncheck feature is not available") } loadCfg := &packages.Config{ @@ -83,11 +83,11 @@ func (v *vulncheck) Run(ctx context.Context, args ...string) error { res, err := opts.Hooks.Govulncheck(ctx, loadCfg, pattern) if err != nil { - return tool.CommandLineErrorf("govulncheck failed: %v", err) + return fmt.Errorf("vulncheck failed: %v", err) } data, err := json.MarshalIndent(res, " ", " ") if err != nil { - return tool.CommandLineErrorf("failed to decode results: %v", err) + return fmt.Errorf("vulncheck failed to encode result: %v", err) } fmt.Printf("%s", data) return nil