go语言学习-IDE
IDE选择:目前go语言最受欢迎的IDE:goland、VS code,目前选择免费的VS code,
下载安装VS code,扩展-搜索go ,安装

随便创建一个.go文件,打开,提示安装go tools,选择install all,会连接到github,自动安装
安装失败,网络连接问题,都懂
像python一样,要添加国内源,命令行输入
go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.cn,direct
再次安装,就可以了
编译一个go文件,出现错误:
错误:go Build Error: go build -o -gcflags all=-N -l . go: go.mod file not found in current directory or any parent directory;
这是因为对MODULE设置的问题,如果没有配置gomod则出错
解决:命令行输入
go env -w GO111MODULE=auto
编译器会自行判断当前项目有无go mod,若没有则使用go path
或者cd 到当前项目目录下(假设为example)初始化go mod
go mod init example
浙公网安备 33010602011771号