Windows下Visual Studio Code配置GoLang开发环境

目录

一、go环境安装配置

二、Visual Studio Code安装

三、配置Go插件

四、安装Go工具

五、Hello World


一、go环境安装配置

下载地址:https://golang.org/dl/

本次下载的版本是go1.15.5.windows-amd64.msi,双击即可安装

环境变量里配置Path添加go安装路径的bin目录,我这里是D:\Go\bin

如果想修改默认workspace可以修改环境变量里的GOPATH参数,默认%USERPROFILE%\go

二、Visual Studio Code安装

下载地址:https://code.visualstudio.com/

安装步骤省略,本次下载的版本是:

Version: 1.51.1 (user setup)
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:34:32.027Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

三、配置Go插件

View->Extensiodins 或者 左侧点击Extensiodins面板,输入go,点击安装

建议开启自动保存,File->Auto Save

四、安装Go工具

集成安装命令,拷贝至CMD即可安装,安装完成后重启Visual Studio

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

五、Hello World

新建go文件,输出Hello World,Run->Run without Debugging,选择Go

package main

import "fmt"

func main() {

	fmt.Println("Hello, world")
}

可以看到有智能提示

执行结果

命令行执行

猜你喜欢

转载自blog.csdn.net/xlyrh/article/details/109777748