From 7690e88544474e497bd9d1946217fd4263787b21 Mon Sep 17 00:00:00 2001 From: Anthony Cicchetti Date: Sat, 1 May 2021 20:22:51 -0400 Subject: [PATCH] Only install gopls when go exists --- zsh/funcs/gopls | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/zsh/funcs/gopls b/zsh/funcs/gopls index 256a9e9..18fbb6b 100644 --- a/zsh/funcs/gopls +++ b/zsh/funcs/gopls @@ -1,10 +1,12 @@ -local GO_BIN="$(go env GOPATH)/bin" -if [[ ! -d "${GO_BIN}" ]]; then - mkdir -p "${GO_BIN}" -fi +if [[ $(whence -p go 2> /dev/null) ]]; then + local GO_BIN="$(go env GOPATH)/bin" + if [[ ! -d "${GO_BIN}" ]]; then + mkdir -p "${GO_BIN}" + fi -if [[ ! -a "${GO_BIN}/gopls" ]]; then - pushd "${GO_BIN}" - GO111MODULE=on go get golang.org/x/tools/gopls@latest - popd + if [[ ! -a "${GO_BIN}/gopls" ]]; then + pushd "${GO_BIN}" + GO111MODULE=on go get golang.org/x/tools/gopls@latest + popd + fi fi \ No newline at end of file