当前位置:网站首页>Go语言 | 01 WSL+VSCode环境搭建避坑指南
Go语言 | 01 WSL+VSCode环境搭建避坑指南
2022-07-05 18:44:00 【“逛丢一只鞋”】
前言
因为工作原因,需要使用Go语言进行开发,作为一个嵌入式开发人员,兵来将挡水来土掩
Go 语言被设计成一门应用于搭载 Web 服务器,存储集群或类似用途的巨型中央服务器的系统编程语言。
对于高性能分布式系统领域而言,Go 语言无疑比大多数其它语言有着更高的开发效率。它提供了海量并行的支持,这对于游戏服务端的开发而言是再好不过了。
Go安装包下载安装
https://studygolang.com/dl
开发环境为WSL,所以直接选择Linux版本下载

下载后找个位置解压文件
执行解压指令
tar zxvf go1.18.3.linux-amd64.tar.gz

把解压后的go文件夹复制到home目录下,也可以自己定义,不过要记得自己的的这个目录
开始配置环境
建议在同一目录下建立go语言工作环境文件夹,我这里新建了一个gopath文件夹,路径为/home/gopath。

sudo nano /etc/profile
然后在打开的文件末尾添加:
export GOROOT=/home/go
export GOPATH=/home/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GOPROXY="https://goproxy.io"
source .bash_profile
再然后刷新文档
source /etc/profile
这里的环境是全局的
最后运行
go version

这两个目录根据自己情况填写export GOROOT=/home/go;export GOPATH=/home/gopath
查看安装情况
这里准备了一个示例代码
保存为 .go 格式的文件
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
执行
go run test.go
可以看到
表示Go下载和安装成功,但是我们肯定不能止步于此,要让开发变得人性化
需要借用VSCode
VSCode搭建
从Windows打开我们的VSCode,然后远程到WSL
安装Go插件
如果我们直接将示例代码进行F5运行,提示需要安装一些包
直接点击大概率是安装失败的
我们要单独进行操作,因为dlv主要牵扯到debug调试
也是决定了我们开发幸福指数的重要工具
dlv安装
go install github.com/go-delve/delve/cmd/[email protected]

在确认安装了GCC之后,根据提示返回VSCode再次安装dlv
稍等片刻
就可以看到提示成功字样
此时F5,发现依然无法运行
解决办法:
go env -w GO111MODULE=auto

OK!环境成功搭建
边栏推荐
- 什么是文本挖掘 ?「建议收藏」
- 7-2 keep the linked list in order
- How to quickly advance automated testing? Listen to the personal feelings of the three bat test engineers
- XML基础知识概念
- Is the performance evaluation of suppliers in the fastener industry cumbersome? Choose the right tool to easily counter attack!
- android中常见的面试题,2022金九银十Android大厂面试题来袭
- The road of enterprise digital transformation starts from here
- C final review
- 泰山OFFICE技术讲座:由行的布局高度,谈绘制高度的高度溢出、高度缩水(全网首发)
- CDB 实例的启动与关闭
猜你喜欢

彻底理解为什么网络 I/O 会被阻塞?

The era of Web3.0 is coming. See how Tianyi cloud storage resources revitalize the system to enable new infrastructure (Part 2)

ICML2022 | 长尾识别中分布外检测的部分和非对称对比学习

Take a look at semaphore, the current limiting tool provided by JUC

MySQL优化六个点的总结
![[detailed explanation of AUTOSAR 14 startup process]](/img/c4/5b08b43db97d8bb10c7207005f8c0a.png)
[detailed explanation of AUTOSAR 14 startup process]

How to quickly advance automated testing? Listen to the personal feelings of the three bat test engineers

The road of enterprise digital transformation starts from here

Word查找红色文字 Word查找颜色字体 Word查找突出格式文本
![2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]](/img/c9/f4ab4578029cf043155a5811a64489.png)
2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]
随机推荐
SAP feature description
Reading notes of Clickhouse principle analysis and Application Practice (5)
The easycvr authorization expiration page cannot be logged in. How to solve it?
Shang Silicon Valley Shang preferred project tutorial release
为什么 BI 软件都搞不定关联分析?带你分析分析
XML基础知识概念
Redhat7.4 configure Yum software warehouse (rhel7.4)
出海十年:新旧接力,黑马崛起
国内低代码开发平台靠谱的都有哪些?
Overview of video self supervised learning
Mathematical modeling of oil pipeline layout MATLAB, mathematical model of oil pipeline layout
uniapp获取微信头像和昵称
Technology sharing | interface testing value and system
机器学习基础(三)——KNN/朴素贝叶斯/交叉验证/网格搜索
跨境支付平台 XTransfer 的低代码实践:如何与其他中台融合是核心
R语言使用lubridate包处理日期和时间数据实战
Powerful tool for collection processing
2022 Alibaba Android advanced interview questions sharing, 2022 Alibaba hand Taobao Android interview questions
从外卖点单浅谈伪需求
2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]