History

go: better logging if `go install gopls` fails (#8060)

Release Notes: - Improved logging if installing `gopls` fails

Thorsten Ball committed 2 years ago

Commit 80db4681 parent 0d2ad671 file · +10 −4Browse files

Unified · Split

crates/zed/src/languages/go.rs+10−4
@@ -125,10 +125,16 @@ impl super::LspAdapter for GoLspAdapter { · 124 unmodified lines
125 .args(["install", "golang.org/x/tools/gopls@latest"])125 .args(["install", "golang.org/x/tools/gopls@latest"])
126 .output()126 .output()
127 .await?;127 .await?;
128 anyhow::ensure!(128
129 install_output.status.success(),129 if !install_output.status.success() {
130 "failed to install gopls. Is `go` installed and in the PATH?"130 log::error!(
131 );131 "failed to install gopls via `go install`. stdout: {:?}, stderr: {:?}",
132 String::from_utf8_lossy(&install_output.stdout),
133 String::from_utf8_lossy(&install_output.stderr)
134 );
135
136 return Err(anyhow!("failed to install gopls with `go install`. Is `go` installed and in the PATH? Check logs for more information."));
137 }
132 138
133 let installed_binary_path = gobin_dir.join("gopls");139 let installed_binary_path = gobin_dir.join("gopls");
134 let version_output = process::Command::new(&installed_binary_path)140 let version_output = process::Command::new(&installed_binary_path)