在vscode中 按 ctrl + shift +p 打開命令窗口,輸入 go 然後選install/Update tools,彈出go插件列表,選擇 全部勾選,確認安裝。
不出意外會失敗,因爲vscode 利用 go get下載,而部分插件在國內訪問不到,所以需要配置代理。
終端輸入:
設置你的 bash 環境變量
echo "export GOPROXY=https://goproxy.io" >> ~/.profile && source ~/.profile
#如果你的終端是 zsh,使用以下命令
echo "export GOPROXY=https://goproxy.io" >> ~/.zshrc && source ~/.zshrc
重新執行以上 vscode 安裝即可成功。