今天对接别人api的时候,对方引用了kubernetes下的client-go,具体信息如下:
{
"ImportPath": "k8s.io/client-go/pkg/api/v1","Comment": "v4.0.0-beta.0","Rev": "df46f7f13b3da19b90b8b4f0d18b8adc6fbf28dc" }
@H_404_0@为了使用对方代码中的struct,我也下载并放置到相应的位置,但仍然报错,具体错误信息如下:
@H_404_0@Cannot use ss(type k8sClient.ResourceName) as type ResourceName in map index )@H_404_0@TenantStatus、ResourceList、ResourceName定义如下:
Reports invalid index and slice expressions.
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
@H_404_0@从截图可以看出idea对于我本地的ResourceName,并不识别
list.Status.Hard[ss].Add(item.Status.Hard["requests.cpu"])
@H_404_0@通过goland进入list.Status.Hard具体定义可以发现,此处引用是对方vendor中的client-go //k8sClient "k8s.io/client-go/pkg/api/v1"
var ss k8sClient.ResourceName
@H_404_0@通过goland进入k8sClient.ResourceName具体定义可以发现,此处引用是我本地的client-go @H_404_0@于是,决定删除对方项目vendor中的client-go包,问题解决。
@H_404_0@个人微信公众号:
@H_404_0@作者:jiankunking 出处:http://blog.csdn.net/jiankunking