大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
vscode安装
百度下载可执行文件,一路next
golang安装
下载地址为: https://golang.google.cn/dl/
如果是linux环境,解压到某个目录。然后配置/etc/profile设置相关环境变量
如果是windows环境,下载https://dl.google.com/go/go1.13.5.windows-amd64.msi,然后设置环境变量。
环境变量为:
GOPATH:%USERPROFILE%\go
GOPROXY:https://goproxy.cn
GOROOT:C:\Program Files (x86)\go
Path环境变量,追加一条:C:\Program Files\Git\bin
打开dos,输入go env,看到一下则说明安装golang成功(在新版本的vscode中,这个 不需要手工输入命令,点击vscode右下角提示让你安装,点击Install All就可以):
Admin@PS20190603LEKJ MINGW64 ~/go/src
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Admin\AppData\Local\go-build
set GOENV=C:\Users\Admin\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Admin\go
set GOPRIVATE=
set GOPROXY=https://goproxy.io
set GOROOT=C:\Program Files (x86)\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files (x86)\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Admin\AppData\Local\Temp\go-build901510026=/tmp/go-build -gno-record-gcc-switches
Admin@PS20190603LEKJ MINGW64 ~/go/src
git安装
安装git windows客户端
设置环境变量:
Path追加:
C:\Program Files\Git\cmd
C:\Program Files\Git\bin
vscode golang插件安装
由于一些技术原因,golang的安装包不能被安装。因此需要手动下载
进行如下命令进行目录切换:
cd %GOPATH%\src\github.com\golang
我这里的GOPATH是在D:\GoPath,大家这里一定要注意些
如果src目录下面没有github.com\golang文件夹请自行创建
完成目录切换后,开始下载插件包,在切换后的目录下进入命令行界面,可以用git bash:
git clone https://github.com/golang/tools.git tools
例如以下命令如果安装不成功:
go install github.com/nsf/gocode
则先用git下载相关go插件的源码,至/c/Users/Admin/go/src目录,然后
git clone https://github.com/nsf/gocode
mkdir -p github.com/nsf
mv gocode github.com/nsf/
安装:
```shell
Admin@PS20190603LEKJ MINGW64 ~/go/src
$ mv gocode github.com/nsf/
Admin@PS20190603LEKJ MINGW64 ~/go/src
$ go install github.com/nsf/gocode
Admin@PS20190603LEKJ MINGW64 ~/go/src
如果用git下载再安装比较麻烦,用下面一个操作:
Admin@PS20190603LEKJ MINGW64 ~/go/src
$ go get -u -v github.com/nsf/gocode
github.com/nsf/gocode (download)
Admin@PS20190603LEKJ MINGW64 ~/go/src
vscode常用的golang插件列表如下:
切换到C:\Users\Admin\go\src目录
go get -u github.com/go-delve/delve/cmd/dlv
go get -v github.com/ramya-rao-a/go-outline
go get -v github.com/rogpeppe/godef
go get -v golang.org/x/tools/cmd/gopls
go get -v github.com/ramya-rao-a/go-outline
go get -v golang.org/x/tools/go/gcexportdata
go get -v github.com/mdempsky/gocode
go get -v golang.org/x/tools/cmd/guru
go get -v golang.org/x/tools/cmd/gorename
go get -v golang.org/x/lint/golint
go get -v golang.org/x/tools/cmd/gopls
go get -v github.com/fatih/gomodifytags
go get -v github.com/josharian/impl
go get -v github.com/godoctor/godoctor
go get -v golang.org/x/tools/imports
go get -v github.com/haya14busa/goplay/cmd/goplay
go get -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -v github.com/acroca/go-symbols
go get -u -v github.com/lukehoban/go-find-references
go get -v golang.org/x/tools/cmd/gorename
go get -v github.com/tpng/gopkgs
go get -v github.com/newhook/go-symbols
go get -u -v github.com/mdempsky/gocode
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)
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "LaunchGo",
"type": "go",
"request": "launch",
"mode": "auto",
"remotePath": "",
"port": 5546,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"GOPATH": "E:/GoCode",
"GOROOT": "C:/Program Files/Go"
},
"args": [],
//"showLog": true
}
]
}
.vscode/settings.json
{
"editor.wordWrap": "on",
"editor.minimap.renderCharacters": false,
"editor.minimap.enabled": false,
"terminal.external.osxExec": "iTerm.app",
//"go.useLanguageServer": true,
"go.docsTool": "gogetdoc",
"go.testFlags": ["-v","-count=1"],
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatTool": "goreturns",
"go.gocodeAutoBuild": false,
"go.goroot": "C:\\Program Files\\Go",
"go.gopath": "E:\\GoCode",
"go.autocompleteUnimportedPackages": true,
"go.formatOnSave": true,
"window.zoomLevel": 0,
"debug.console.fontSize": 16,
"debug.console.lineHeight": 30,
"[javascript]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"[html]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/184113.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...