当前位置:网站首页>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
边栏推荐
- China creates vast research infrastructure to support ambitious climate goals
- MySQL [read / write lock + table lock + row lock + mvcc]
- JS brain burning interview question reward
- [code analysis (1)] communication efficient learning of deep networks from decentralized data
- leetcode--380.O(1) 时间插入、删除和获取随机元素
- Android篇:2019初中级Android开发社招面试解答(中
- Choreographer full resolution
- RAC environment alert log error drop transient type: systp2jw0acnaurdgu1sbqmbryw = = troubleshooting
- Strange bug of cnpm
- Core concepts of microservice architecture
猜你喜欢
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
Postman reference summary
Leetcode brush question 897 incremental sequential search tree
Handling of high usage of Oracle undo
Port occupied 1
2022年江西最新建筑八大员(质量员)模拟考试题库及答案解析
Leetcode brush question 𞓜 13 Roman numeral to integer
ACFs file system creation, expansion, reduction and other configuration steps
Dolphin scheduler configuring dataX pit records
Information: 2021 / 9 / 29 10:01 - build completed with 1 error and 0 warnings in 11S 30ms error exception handling
随机推荐
pycharm Install packages failed
Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough
Building MySQL environment under Ubuntu & getting to know SQL
服务器中挖矿病毒了,屮
[code analysis (2)] communication efficient learning of deep networks from decentralized data
Dynamic subset division problem
第一章 电商秒杀商品回顾
[code analysis (5)] communication efficient learning of deep networks from decentralized data
AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
Apache Atlas Compilation and installation records
China creates vast research infrastructure to support ambitious climate goals
MySQL [SQL performance analysis + SQL tuning]
L2-024 部落 (25 分)
Detailed explanation of redis (Basic + data type + transaction + persistence + publish and subscribe + master-slave replication + sentinel + cache penetration, breakdown and avalanche)
2021年秋招,薪资排行NO
Neuron and neural network
freeCodeCamp----time_ Calculator exercise
SQL learning | complex query
【项目】小帽外卖(八)
初探 Lambda Powertools TypeScript