当前位置:网站首页>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!环境成功搭建
边栏推荐
- #夏日挑战赛# HarmonyOS - 实现消息通知功能
- 决策树与随机森林
- 面试官:Redis 过期删除策略和内存淘汰策略有什么区别?
- Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
- 5. Data access - entityframework integration
- 公司破产后,黑石们来了
- Simple query cost estimation
- 蚂蚁集团开源可信隐私计算框架「隐语」:开放、通用
- Various pits of vs2017 QT
- How to quickly advance automated testing? Listen to the personal feelings of the three bat test engineers
猜你喜欢
Word finds red text word finds color font word finds highlighted formatted text
AI金榜题名时,MLPerf榜单的份量究竟有多重?
图扑软件数字孪生 | 基于 BIM 技术的可视化管理系统
出海十年:新旧接力,黑马崛起
Teach you to deal with JS reverse picture camouflage hand in hand
A cloud opens a new future of smart transportation
手把手教你处理 JS 逆向之图片伪装
一朵云开启智慧交通新未来
Tupu software digital twin | visual management system based on BIM Technology
Blue sky drawing bed Apple quick instructions
随机推荐
How much does the mlperf list weigh when AI is named?
A cloud opens a new future of smart transportation
开源 SPL 消灭数以万计的数据库中间表
【历史上的今天】7 月 5 日:Google 之母出生;同一天诞生的两位图灵奖先驱
CDB 实例的启动与关闭
ROS installation error sudo: rosdep: command not found
EMQX 5.0 正式发布:单集群支持 1 亿 MQTT 连接
数学分析_笔记_第9章:曲线积分与曲面积分
2022 latest Android interview written examination, an Android programmer's interview experience
[today in history] July 5: the mother of Google was born; Two Turing Award pioneers born on the same day
Low code practice of xtransfer, a cross-border payment platform: how to integrate with other medium-sized platforms is the core
2022全网最全的腾讯后台自动化测试与持续部署实践【万字长文】
Oracle Chinese sorting Oracle Chinese field sorting
7-2 keep the linked list in order
Advanced application of C # language
2022最新Android面试笔试,一个安卓程序员的面试心得
自动化测试的好处
图扑软件数字孪生智慧风电系统
小程序 修改样式 ( placeholder、checkbox的样式)
5年经验Android程序员面试27天,2022程序员进阶宝典