我正在使用operator-sdk,并且发现VSCode和CLI之间的行为不一致。
当我使用operator-sdk run --local
运行时,会看到以下内容。但是VSCode没有显示任何错误。我不太确定为什么会这样或问题在哪里。
pkg/controller/mypackage/mycontroller_controller.go:207:4: cannot use testRef (type *"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1".PipelineRef) as type "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1".PipelineRef in field value
有问题的代码如下。
//...declaration
testRef := &tekton.PipelineRef{
Name: "mypipeline",
}
//..usage later...
Spec: tekton.PipelineRunSpec{
PipelineRef: testRef,
Params: []tekton.Param{{
我正在使用gomodules,而相关的模块是-> github.com/tektoncd/pipeline v0.10.0
我了解这与指针引用以及将代码更改为
有关testRef := tekton.PipelineRef{
Name: "mypipeline",
}
然后VSCode显示如下错误,但是CLI不会报告任何错误。
cannot use testRef (variable of type v1alpha1.PipelineRef) as *v1alpha1.PipelineRef value in struct literal
这仅仅是一个模块依赖性问题,我的上游API发生了变化吗?也许我的CLI和VSCode正在读取不同的依赖项?我什至不知道从哪里开始……任何指针(双关语都可以理解)。