当前位置:网站首页>VsCode-Go
VsCode-Go
2022-04-23 13:59:00 【面试被拒1万次】
使用Vscode 调试go
安装好[Vscode](https://code.visualstudio.com/)
安装好[Go](https://go.dev/dl/)
Windows 下载.msi后缀名的包,
mac 下载.pkg后缀名的包,
linux 下载后缀名 tar.gz (解压 tar -zxvf 包名)
> go 默认安装在 C:\Program Files\GO 或者 C:\User\GO 具体哪一我忘了,我一般默认安装在C"\的根目录下
编辑环境变量
Windows:
个人用户环境变量:
GOPATH(变量名) : C:\Go\bin (变量值)
Path(变量名) : C:\Go\bin (变量值)
系统变量:
Path(变量名) : C:\Go\bin (变量值)
linux
vi /etc/profile,
写入 export PATH=$PATH:/usr/local/go/bin 退出
source /etc/profile
安装好环境,进入终端 输入go version ,如果没有显示版本,就重启电脑。。。。
使用Vscode 配置Go环境
使用Vscode 下载一个GO的扩展包,打开一个Go的项目文件夹,没有就创建一个,使用VsCode打开这个文件夹
建立测试代码
main.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World")
fmt.Println("Hello World")
}
会提示药安装插件,由于某些已知问题,下载有点麻烦,我直接把我下载打一个包
Go插件包,解压放在安装go文件夹的bin下面
设置go env
go env -w GO111MODULE=on //go命令行会使用modules
go env -w GOPROXY=https://goproxy.cn,direct // 使用七牛云的
设置 launch.json
新版的Vscode 不需要设置GOPATH 和 GOROOT,打开Vscode 运行 >> 添加配置
{
"version": "0.2.0",
"configurations": [
{
"type": "go",
"request": "launch",
"name": "Launch",
"mode":"debug",
"program": "${file}"
}
]
}
初始化mod
go mod init 项目文件夹名
可以试着调试了,注意要在main.go的文件启动F5调试,注意main.go的包名一定是 “package main”。
关于go mod是go1.11项目管理模块,学习这块模块的可以访问 go mod学习
配置问题,可以看看这个博客 配置学习
配置问题,可以看看这个博客 配置学习
版权声明
本文为[面试被拒1万次]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_38023160/article/details/122153840
边栏推荐
- Introduction to spark basic operation
- Express中间件③(自定义中间件)
- About me
- [code analysis (5)] communication efficient learning of deep networks from decentralized data
- Chapter 15 new technologies of software engineering
- Influence of openssh version on SSH mutual trust creation in RAC environment
- 函数只执行第一次的执行一次 once函数
- Pytorch 经典卷积神经网络 LeNet
- JS 力扣刷题 102. 二叉树的层序遍历
- Ora-600 encountered in Oracle environment [qkacon: fjswrwo]
猜你喜欢
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
SQL learning | set operation
Basic SQL query and learning
About note 1
PG SQL intercepts the string to the specified character position
Express ② (routage)
Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
Building MySQL environment under Ubuntu & getting to know SQL
随机推荐
Move blog to CSDN
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
China creates vast research infrastructure to support ambitious climate goals
Express ② (routing)
MySQL [SQL performance analysis + SQL tuning]
[code analysis (4)] communication efficient learning of deep networks from decentralized data
33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?
Quartus prime hardware experimental development (de2-115 board) experiment 1 CPU instruction calculator design
Reading notes: fedgnn: Federated graph neural network for privacy preserving recommendation
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
Force deduction brush question 101 Symmetric binary tree
Es introduction learning notes
Pytorch 经典卷积神经网络 LeNet
elmo(BiLSTM-CRF+elmo)(Conll-2003 命名实体识别NER)
Spark入门基本操作
Reading notes: meta matrix factorization for federated rating predictions
编程旅行之函数
Quartus Prime硬件实验开发(DE2-115板)实验二功能可调综合计时器设计
Multithreading