0.vscode安装
已安装
1.安装插件
安装第一个

2.构建第一个Go程序
https://www.youtube.com/watch?v=1MXIGYrMk80
2.1新建一个文件夹

使用vscode打开

2.2打开终端新建一个模块
后面的地址,可以随意填写,不连接真实网站
Go
go mod init demo/demo.com


2.3新建.go文件
在go.mod同级新建一个文件夹,文件夹新建一个.go文件
mascot/mascot.go

发现右下角提示缺少工具,点击安装,下载慢,先修改代理(win)
Go
go env -w GOPROXY=https://goproxy.cn,direct


mascot.go中编写以下代码
Go
package mascot
// demo
func BestMascot() string{
return "Tux"
}
2.4新建主入口文件main.go
在go.mod同级目录新建一下文件main.go

main.go中编写以下代码
Go
package main
import (
"demo/demo.com/mascot"
"fmt"
)
func main() {
fmt.Println(mascot.BestMascot())
}
3.运行go程序
打开终端运行以下代码
Go
go run main.go
输出Tux
