windows10wsl2安装go笔记

1.检查windows10版本支持情况

windows+r  打开运行,输入winver 查看版本 是不是大于1903

2.启用适用于 Linux 的 Windows 子系统

开始-设置-应用-拉到最下-程序功能--启用关闭windows功能--适用于linux的windows子系统

或者powershell (管理员运行)执行:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

 启用虚拟机功能

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

3.重启windows,下载更新包安装

 

4.将wsl2设置为默认版本

wsl --set-default-version 2

5.windows store 安装Ubuntu

如果遇到如下提示需要安装更新包

Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x800701bc Error: 0x800701bc WSL 2 ?????????????????? https://aka.ms/wsl2kernel Press any key to continue...

适用于 x64 计算机的 WSL2 Linux 内核更新包

6.设置root作为默认用户(powershell 管理员)

ubuntu config --default-user root

 

参考:

1.安装WSL2并下载配置Ubuntu

2.WSL-Ubuntu中默认以ROOT用户登陆的方式

 

#####安装protobuf(Ubuntu为例)

在执行shell脚本时, 提示 autoreconf: not found
 是因为 没有安装 automake, just to do below:

sudo apt-get update  

#如果上述命令执行太慢,可以更换源 

sudo apt-get install autoconf automake libtool

sudo apt-get install autoconf  automake  libtool curl make  g++  unzip libffi-dev -y
cd protobuf/ 
./autogen.sh 
./configure
make  && sudo make install
# 刷新共享库
sudo ldconfig  
# 成功后测试
protoc -h 

 

参考: protobuf 安装 - 知乎 (zhihu.com)

 #####安装go

wget https://go.dev/dl/go1.17.6.linux-amd64.tar.gz

如果太慢,使用阿里云镜像 阿里云开源镜像站资源目录 (aliyun.com)

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.6.linux-amd64.tar.gz

 修改 .bashrc 或者.profile

export PATH=$PATH:/usr/local/go/bin

go version 

 




 

posted on 2022-02-10 13:54  iokde.com  阅读(336)  评论(0编辑  收藏  举报

导航