问题:无法跳转到定义在其他文件的方法 (如下图所示)
解决方法:
- 打开 shell
- 安装 GO
sudo apt-get update
sudo apt install -y wget
sudo wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
sudo tar -xvf go1.9.2.linux-amd64.tar.gz
sudo mv go /usr/local - GOPATH 和 GOROOT
export GOPATH=~/k8s
export GOROOT=/usr/local/go
- 下载代码: sudo git clone https://github.com/kubernetes/kubernetes $GOPATH
- 安装 VS Code
-
安装 Dockercurl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code
sudo -H -u $LOCALUSER bash -c "code --install-extension lukehoban.Go"sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable"
sudo apt-get update && sudo apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 17.12 | head -1 | awk '{print $3}')
- 设置Kubernetes路径
cd $GOPATH
ln -sf staging/src src
cd $GOPATH/staging/src/k8s.io
ln -sf $GOPATH kubernetes - 编译
cd $GOPATH
build/run.sh make what=cmd/hyperkube - 直接编译Hyperkube
cd $GOPATH/src/k8s.io/kubernetes/cmd/hyperkube
go build -gcflags "-l -N" - 打开Kubernetes 代码
code $GOPATH - 找到文件 /home/honcao/k8s/src/k8s.io/kubernetes/cmd/hyperkube/main.go