Golang Cannot use ss(type AAA) as type AAA in map index
問題出現的背景:
今天對接別人api的時候,對方引用了kubernetes下的client-go,具體資訊如下:
{
"ImportPath": "k8s.io/client-go/pkg/api/v1",
"Comment": "v4.0.0-beta.0",
"Rev": "df46f7f13b3da19b90b8b4f0d18b8adc6fbf28dc"
}
為了使用對方程式碼中的struct,我也下載並放置到相應的位置,但仍然報錯,具體錯誤資訊如下:
Cannot use ss(type k8sClient.ResourceName) as type ResourceName in map index )
Reports invalid index and slice expressions.
TenantStatus、ResourceList、ResourceName定義如下:
type TenantStatus struct {
Phase TenantPhase `json:"phase"`
ActualUsed v1.ResourceList `json:"actualUsed"`
Used v1.ResourceList `json:"used"`
Hard v1.ResourceList `json:"hard"`
}
// ResourceList is a set of (resource name, quantity) pairs.
type ResourceList map[ResourceName]resource.Quantity
// ResourceName is the name identifying various resources in a ResourceList.
type ResourceName string
從截圖可以看出idea對於我本地的ResourceName,並不識別
list.Status.Hard[ss].Add(item.Status.Hard["requests.cpu"])
通過goland進入list.Status.Hard具體定義可以發現,此處引用是對方vendor中的client-go
//k8sClient "k8s.io/client-go/pkg/api/v1"
var ss k8sClient.ResourceName
通過goland進入k8sClient.ResourceName具體定義可以發現,此處引用是我本地的client-go
於是,決定刪除對方專案vendor中的client-go包,問題解決。
個人微信公眾號:
作者:jiankunking 出處:http://blog.csdn.net/jiankunking
相關文章
- aaa
- cannot convert (type interface {}) to type int: need type assertion
- ‘map’ does not name a type
- The type List is not generic; it cannot …
- Cannot infer type arguments for PageImpl
- Cannot set property ‘type‘ of null(vue)NullVue
- 淺談Elasticsearch的AAA (I)Elasticsearch
- xxx cannot be resolved to a type
- 【RabbitMQ】direct type exchange example in golangMQGolang
- 【RabbitMQ】topic type exchange example in golangMQGolang
- 【RabbitMQ】fanout type exchange example in golangMQGolang
- MYSQL中的type:index 和 Extra:Using indexMySqlIndex
- TGDC | Evolving AAA Game DevelopmentGAMdev
- variable: Type 與 Type variable
- 解決 TypeError: Type aliases cannot be used with isinstance(). 辦法Error
- Value Type vs Reference Type in SwiftSwift
- golang使用sqlx報錯:unsupported type []interface {}, a slice of interfaceGolangSQL
- 解決java.lang.IllegalArgumentException: 'Content-Type' cannot contain wildcard type '*'異常(真實有效)...JavaExceptionAI
- FatalThrowableError in index.php line 554:Type error: Argument 1 passedErrorIndexPHP
- 【協議】AAA Radius協議的常用報文分析協議
- AAA:汽車AEB在預防撞車方面越來越出色
- 解決javax.servlet.jsp.JspException cannot be resolved to a typeJavaServletJSException
- Material type ROH cannot be used with item category L (plant T001)Go
- The type XXX cannot be resolved.It is indirectly referenced from required .classUI
- Type in Chakra
- HITSC_4_Data Type and Type Checking
- 20171229V$DB_OBJECT_CACHE type='INDEX'ObjectIndex
- 超級AAA類遊戲的價值特徵和研發要求遊戲特徵
- AAA:66%的美國司機擔憂自動駕駛汽車技術自動駕駛
- java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy7 implemJavaException
- A resource type with the name 'ora.daemon.type' is already registered
- oracle enqueue typeOracleENQ
- jQuery.type()jQuery
- oracle block type!OracleBloC
- Type classes in Scala
- block corruption typeBloC
- [PLT] Type system
- The type MultipartEntity is deprecated