VS Code with GO
source link: https://studygolang.com/articles/32131
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
安装Go 语言包
Windows下安装(最新)
双击你下载的安装包(go1.13.4.windows-amd64.msi),一直点击“Next”即可,注意有一步要求选择安装路径,为了后面教程好说明请不要更改。
然后点“Install”安装
这个过程请等待
点击“Finish”完成安装
怎么来验证我们的安装是成功的呢?按windows键+R,输入:cmd回车
在出现的命令行窗口输入:go version回车,这时会显示你当前安装的go版本,说明咱们已经安装成功了
安装VSCode
打开官网https://code.visualstudio.com/Download,进入下载页后,找到下载的地方如下图:
win10 64 bit点击第一处红箭头指向处下载,CentOS 64 bit点第二处箭头指向处下载
2、windows下安装
双击你下载的安装程序,然后按下图顺序一路点击
安装VSCode中文包
如果你和笔者一样英文很low,你可以选择安装中文语言包
先可以点左侧第五个图标,或按快捷键Ctrl+Shift+X 打开Extensions,在搜索框里输入:language,中文(简体)的包,然后点“Install”安装,如下图
重新打开VSCode,这时已经是中文的啦
安装go插件
打开Extensions,输入go,安装作者Microsoft的这个
安装vscode-go
对于Visual Studio Code开发工具,有一款优秀的GoLang插件,它的主页为:https://github.com/microsoft/vscode-go
这款插件的特性包括:
Colorization 代码着彩色
Completion Lists 代码自动完成(使用gocode)
Snippets 代码片段
Quick Info 快速提示信息(使用godef)
Goto Definition 跳转到定义(使用godef)
Find References 搜索参考引用(使用go-find-references)
File outline 文件大纲(使用go-outline)
Workspace symbol search 工作区符号搜索(使用 go-symbols)
Rename 重命名(使用gorename)
Build-on-save 保存构建(使用go build和go test)
Format 代码格式化(使用goreturns或goimports或gofmt)
Add Imports 添加引用(使用 gopkgs)
Debugging 调试代码(使用delve)
集成安装命令,拷贝到cmd窗口就可完成安装:
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
1、在GoPath中新建一个文件夹GoHello,打开VSCode打开这个文件夹,新建一个文件main.go,在文件中输入以下代码
package main
import (
"fmt"
)
func main() {
fmt.Println("hello world")
}
如果右下角有提示你有些插件需要更新,你可以不面要理会,或直接点更新,如图提示:Your version of go-outline appears to be out of date. Please update for an improved experience.
有疑问加站长微信联系(非本文作者)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK