当前位置:网站首页>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!环境成功搭建
边栏推荐
- Powerful tool for collection processing
- Low code practice of xtransfer, a cross-border payment platform: how to integrate with other medium-sized platforms is the core
- Interprocess communication (IPC): shared memory
- JS解力扣每日一题(十二)——556. 下一个更大元素 III(2022-7-3)
- 什么是文本挖掘 ?「建议收藏」
- Overview of video self supervised learning
- cf:B. Almost Ternary Matrix【对称 + 找规律 + 构造 + 我是构造垃圾】
- 开源 SPL 消灭数以万计的数据库中间表
- Optimization of middle alignment of loading style of device player in easycvr electronic map
- 5年经验Android程序员面试27天,2022程序员进阶宝典
猜你喜欢

RedHat7.4配置yum软件仓库(RHEL7.4)

Idea configuring NPM startup
![[HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD](/img/b8/624799e4bf788e4476b155486f478b.png)
[HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD

Case sharing | integrated construction of data operation and maintenance in the financial industry

Solutions contents have differences only in line separators

视频自监督学习综述
![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]

Rse2020/ cloud detection: accurate cloud detection of high-resolution remote sensing images based on weak supervision and deep learning
![CF: B. almost Ternary Matrix [symétrie + règles de recherche + Construction + I am Construction Waste]](/img/5d/06229ff7cfa144dbcb60ae43d5c435.png)
CF: B. almost Ternary Matrix [symétrie + règles de recherche + Construction + I am Construction Waste]

Oracle date format conversion to_ date,to_ char,to_ Timestamp mutual conversion
随机推荐
华律网牵手观测云,上线系统全链路可观测平台
cf:B. Almost Ternary Matrix【對稱 + 找規律 + 構造 + 我是構造垃圾】
C# 语言的基本语法结构
2022 latest Android interview written examination, an Android programmer's interview experience
5. Data access - entityframework integration
基于FPGA的超声波测距
Take a look at semaphore, the current limiting tool provided by JUC
A cloud opens a new future of smart transportation
Oracle date format conversion to_ date,to_ char,to_ Timestamp mutual conversion
2022 the most complete Tencent background automation testing and continuous deployment practice in the whole network [10000 words]
紧固件行业供应商绩效考核繁琐?选对工具才能轻松逆袭!
C language makes it easy to add, delete, modify and check the linked list "suggested collection"
The era of Web3.0 is coming. See how Tianyi cloud storage resources revitalize the system to enable new infrastructure (Part 2)
The monthly list of Tencent cloud developer community videos was released in May 2022
golang通过指针for...range实现切片中元素的值的更改
7-1 链表也简单fina
RedHat7.4配置yum软件仓库(RHEL7.4)
Common time complexity
Optimization of middle alignment of loading style of device player in easycvr electronic map
潘多拉 IOT 开发板学习(HAL 库)—— 实验8 定时器中断实验(学习笔记)