基于vscode的go环境安装简介
基于vscode的go环境安装简介
安装后测试执行结果图:
一、下载go安装包
go语言下载链接:https://studygolang.com/dl
go1.24.0.windows-amd64.msi
安装到目录 d:\ide\go
设置系统环境变量:
GOROOT=d:\ide\go
设置Path系统变量:
%GOROOT%\bin
或
d:\ide\go\bin
添加系统用户变量:
GOPROXY=https://proxy.golang.com.cn,direct
二、下载vscode安装包
Vscoode下载链接:Download Visual Studio Code - Mac, Linux, Windows
https://code.visualstudio.com/Download
下载安装完后,打开vscode开发环境
在插件中搜索go,下载第一个插件
然后按快捷键Ctrl+Shift+P,输入go:install/update tools 然后全选下载,配置完成
三、测试环境
test.go文件内容:
package mainimport "fmt"func main() {fmt.Println("Hello world!")for i := 1; i <= 2; i++ {for j := 1; j <= 9; j++ {var k = i * jfmt.Println(i, "*", j, "=", k)}fmt.Printf("\r\n")}
}
执行结果:
Executing task: go run ./ Hello world!
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
1 * 5 = 5
1 * 6 = 6
1 * 7 = 7
1 * 8 = 8
1 * 9 = 92 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18* Terminal will be reused by tasks, press any key to close it.
本blog地址:https://blog.csdn.net/hsg77