下载并安装Visual Studio Code Go依赖项 [英] Downloading and installing Visual Studio Code Go dependencies

查看:48
本文介绍了下载并安装Visual Studio Code Go依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在离线计算机上安装了Visual Studio Code和Go扩展程序,现在我需要在该计算机上安装依赖项.
我该怎么办?

I have installed Visual Studio Code and the Go extension on an offline computer and now I need to install the dependencies on that computer.
How can I do it please?

推荐答案

注意:如果您的在线PC和脱机PC具有相同的操作系统和体系结构,只需复制 $ GOPATH 目录,就很好了.

Note: If both of your online and offline PCs have the same OS and architecture, simply copy the $GOPATH directory and you are good to go.

(注意:对于Windows操作系统,将所有 $ GOPATH 替换为%GOPATH%)

(Note: Replace all $GOPATH with %GOPATH% for Windows OS)

转到Go扩展程序所依赖的Go工具,并按照适用于您的操作系统的说明进行操作:

Go to the Go tools that the Go extension depends on, and follow instructions for your OS:

  1. dlv 的示例:

go get -u -v github.com/go-delve/delve/cmd/dlv

语言服务器的示例:

go get -u -v golang.org/x/tools/cmd/gopls

仅此而已.

  1. 对于离线安装,您需要先将这些文件复制到离线计算机中,然后运行例如:
  1. For the offline installation you need first copy these files to the offline computer and just run e.g.:

cd $GOPATH/src/github.com/go-delve/delve/cmd/dlv
go install

为所需的所有软件包重复步骤1和2,或者仅在第一台PC上使用干净的 GOPATH/src ,然后压缩所有文件,然后复制压缩文件并解压缩,然后运行请安装以获取您需要安装的所有软件包.

Repeat steps 1 and 2 for all the packages you need, or simply have a clean GOPATH/src on first PC then compress all, then copy the compressed file and uncompress it then run go install for all packages you need to install.

  1. 转到工具:

在线

最简单的安装方法是运行:

Online

The easiest way to install is to run:

go get -u golang.org/x/tools/...

离线副本

您还可以手动将存储库克隆到以下位置:
$ GOPATH/src/golang.org/x/tools

这篇关于下载并安装Visual Studio Code Go依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆