Kubernetes undefined noderesources.preFilterState

huangapple go评论81阅读模式
英文:

Kubernetes undefined noderesources.preFilterState

问题

我正在重写Kubernetes的NodeResourcesFit插件的逻辑,我想像这个链接中的代码一样使用preFilterStatehttps://github.com/kubernetes/kubernetes/blob/419e0ec3d2512afd8c1f35a44862f856bc4ac10f/pkg/scheduler/framework/plugins/noderesources/fit.go#L91,所以我在代码中导入了它:

import "k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources"

然后像这样使用它:

s, ok := c.(*noderesources.preFilterState)

然而,我遇到了一个错误:undefined: noderesources.preFilterState

我对Kubernetes不太熟悉,所以不知道哪里出错了。谢谢你的耐心。

我尝试打印noderesources.Name,但也失败了。

英文:

I am rewriting the logic of Kubernetes' NodeResourcesFit plugin, I want to use preFilterState like <https://github.com/kubernetes/kubernetes/blob/419e0ec3d2512afd8c1f35a44862f856bc4ac10f/pkg/scheduler/framework/plugins/noderesources/fit.go#L91>, so I import it in the code:

import &quot;k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources&quot;

and use it just like:

s, ok := c.(*noderesources.preFilterState)

However I get an error: undefined: noderesources.preFilterState

I am not familiar with Kubernetes, so I don't know what is wrong with it. Thanks for your patience.

I try to print noderesources.Name but it failed too.

答案1

得分: 1

根据你提供的链接,preFilterState没有被导出,因此无法从包的外部访问。这与Kubernetes无关,而是与Go语言有关:

  • 示例:https://go.dev/tour/basics/3
  • 文档:https://go.dev/doc/effective_go#names

我有一种感觉你刚开始学习Go语言,我建议你先熟悉一下这门语言的基础知识,可以使用一个带有智能感知功能的集成开发环境(IDE)或文本编辑器,这样你就能知道可以调用哪些函数和变量。

英文:

According to the link you're providing, preFilterState is not exported and therefore not accessible from the outside of the package.
It has nothing to do with Kubernetes but with go:

I have a feeling you are starting with go, I recommend you play a bit with the fundamentals of the language and maybe use an IDE/Text editor with intellisense to be able to know what you can and cannot call.

huangapple
  • 本文由 发表于 2023年1月25日 14:22:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75230318.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定