在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
go语言安装 go语言下载地址:https://studygolang.com/dl go语言安装完成后,会将go语言安装目录添加到环境变量中; 1)、添加环境变量
GOROOT:为go语言环境地址; GOPATH:为go的工作目录地址
并在环境变量Path中添加go语言环境的bin目录; 2)、检查go语言是否安装成功
在命令行中输入:go 并回车,则如上所示; 3)、查看版本号 运行 go version
2. vs code 开发工具安装 vs code下载地址:https://code.visualstudio.com/ 3. vs code中安装第三方go语言插件
找到红色方框中Go(即:Rich Go language support for Visual Studio Code)点击安装即可; 4.设置vs code go插件配置 1)、选择设置选项
2)、选择扩展Go configuration选择配置
点击 Go configuration下的 “在settings.json中编辑”,如下图所示:
{"git.ignoreMissingGitWarning":true,"files.autoSave":"onFocusChange","files.encoding":"utf8","files.trimTrailingWhitespace":false,"files.autoSaveDelay":1000,// 保存代码时自动编译"go.buildOnSave":"off",// 保存代码时优化"go.lintOnSave":"package",// 保存代码时检查潜在错误"go.vetOnSave":"package",// 保存代码时执行测试"go.coverOnSave":false,"go.useCodeSnippetsOnFunctionSuggest":true,"go.useCodeSnippetsOnFunctionSuggestWithoutType":true,// 代码格式化"go.formatTool":"goreturns","go.gocodePackageLookupMode":"go","go.gotoSymbol.includeImports":true,"go.docsTool":"godoc","go.inferGopath":true,"go.useLanguageServer":true,"go.autocompleteUnimportedPackages":true,// go语言安装环境目录"go.goroot":"C:\\Go",// go语言工作目录"go.gopath":"E:\\goworks","go.gocodeAutoBuild":false} 3)、打开go语言工作目录,如果打开终端
在工作目录goworks下新建目录src,并创建一个go语言文件,如:test.go文件; 4)、重新启动vs code,会自动加载Go的第三方类库,点单安装所有,安装时会出现如下错误: Installing github.com/mdempsky/gocode FAILED Installing github.com/uudashr/gopkgs/cmd/gopkgs FAILED Installing github.com/ramya-rao-a/go-outline FAILED Installing github.com/acroca/go-symbols FAILED Installing golang.org/x/tools/cmd/guru FAILED Installing golang.org/x/tools/cmd/gorename FAILED Installing github.com/go-delve/delve/cmd/dlv SUCCEEDED Installing github.com/stamblerre/gocode FAILED Installing github.com/rogpeppe/godef SUCCEEDED Installing github.com/sqs/goreturns FAILED Installing golang.org/x/lint/golint FAILED 为避免上述情况,首先在go工作目录的src目录下创建“golang.org/x”目录,然后通过git命令克隆go工具; 进入goworks/src/golang.org/x目录下 运行 git clone https://github.com/golang/tools.git 运行 git clone https://github.com/golang/lint.git 运行 git clone https://github.com/golang/sync.git 安装失败可通过下列方式手动安装: go install github.com/mdempsky/gocode go install github.com/uudashr/gopkgs/cmd/gopkgs go install github.com/ramya-rao-a/go-outline go install github.com/acroca/go-symbols go install golang.org/x/tools/cmd/guru go install golang.org/x/tools/cmd/gorename go install github.com/go-delve/delve/cmd/dlv go install github.com/stamblerre/gocode go install github.com/rogpeppe/godef go install github.com/sqs/goreturns go install golang.org/x/lint/golint go install golang.org/x/tools/gopls 最终结果:
所有插件安装完成后的效果:
|
请发表评论