How to debug kubectl source code in IDE step by step

how to debug kubectl source code step by step in IDE.

I try to debug the kubectl under cmd/kubectl/kubectl.go, the result is an error like below:

currently I can only recompile using make WHAT=cmd/kubectl to verify my guess to the logic of the kubectl source code, that’s not so good.

  • go version: go1.17.5 linux/amd64
  • kubernetes version: v1.21.14