天天看點

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

玩kubenetes client-go時遇到的問題。

解決過程簡單,兩行代碼,過程如下:

兩行代碼複制粘貼:

//将之前的檔案都删除
        k8s.io/apimachinery v0.17.2
        k8s.io/client-go v0.17.2
        //複制粘貼這兩個檔案即可解決問題      

問題描述:

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

報錯對應的go.mod檔案内容:【是go.mod檔案】

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

修改go.mod檔案如下:

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

兩行代碼複制粘貼:

//将之前的檔案都删除
        k8s.io/apimachinery v0.17.2
        k8s.io/client-go v0.17.2
        //複制粘貼這兩個檔案即可解決問題      

修改之後的現象:

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

至此,報錯解決。【一步一步做,錯誤肯定會解決掉】

如果文章幫到你解決問題,關注我,為思考點贊!

解決問題的思路:

(1)看kubenetes client-go中文文檔:【看文檔,軟實力】

https://jimmysong.io/kubernetes-handbook/develop/client-go-sample.html

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

(2)跳轉之後(https://github.com/kubernetes/client-go)

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

還可以看人家的go.mod檔案:

s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

不過我試過複制粘貼,不能解決問題。這個方法可借鑒以後的排錯思路。

經過入坑,用兩條指令解決問題:

//将之前的檔案都删除
        k8s.io/apimachinery v0.17.2
        k8s.io/client-go v0.17.2
        //複制粘貼這兩個檔案即可解決問題