1. 使用 vs-code 来阅读源码

1. 下载源码

地址:https://github.com/kubernetes/kubernetes/releases/tag/v1.25.15

版本自己选择。

下载到本地目录,如:

在这里插入图片描述

k8s-1.25 目录下创建 src/k8s.io 目录,注意目录层次,.githubsrc/k8s.io 下。


2. 使用 vscode

使用 vscode 打开 D:\code\k8s-1.25\src\k8s.io 目录,这时会提示我们下载 go 库,按照提示下载按照即可。安装完成后,打开 cmd,修改镜像源:

go env -w GOPROXY=https://goproxy.io/

接着重启 vscode,这时会提醒我们下载更多依赖库,按照提示下载按照即可。

Installing 8 tools at C:\Go\repository\bin in module mode.
  gotests
  gomodifytags
  impl
  goplay
  dlv
  staticcheck
  gopls
  go-outline
 
Installing github.com/cweill/gotests/gotests@latest (C:\Go\repository\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@latest (C:\Go\repository\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl@latest (C:\Go\repository\bin\impl.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Go\repository\bin\dlv.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@latest (C:\Go\repository\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Go\repository\bin\dlv.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Go\repository\bin\staticcheck.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Go\repository\bin\staticcheck.exe) SUCCEEDED

3. 添加环境变量 GOPATH

我的电脑 -> 属性 -> 高级系统设置 -> 环境变量,添加如下形式 D:\code\k8s-1.25\src\k8s.io\vendor

在这里插入图片描述

然后 kubernetes 本身是支持 gomod 的,但源码这里提供了所有的依赖在 staging/src/k8s.io/ 目录下,可以将此目录内的文件复制到 vendor/k8s.io 目录下即可。

然后重启 vscode,就完成了。

在这里插入图片描述

  • 20
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

华为云计算搬砖工

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值