Golang包依赖问题

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

Golang package dependencies issues

问题

我会帮你翻译这段内容,但是请注意,我只会返回翻译好的部分,不会回答你的问题。

我想在我的控制器中使用以下函数:https://github.com/openshift/machine-api-operator/blob/05041eaab5a6b9e22dd26df421d8d51050c39072/pkg/controller/vsphere/util.go#L221

因此,在我的代码中,我进行了以下导入:

package controllers

import (
	"context"

	vsphere "github.com/openshift/machine-api-operator/pkg/controller"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/types"
	"sigs.k8s.io/controller-runtime/pkg/client"
)

然而,当我运行 go mod tidy 时,出现了以下错误:

bitbucket.bit.admin.ch/BOSC/bosc-drs-vm-group-controller/controllers imports
        github.com/openshift/machine-api-operator/pkg/controller imports
        github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck imports
        sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1: module sigs.k8s.io/cluster-api@latest found (v1.3.2), but does not contain package sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1
bitbucket.bit.admin.ch/BOSC/bosc-drs-vm-group-controller/controllers imports
        github.com/openshift/machine-api-operator/pkg/controller imports
        github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck imports
        github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1 imports
        sigs.k8s.io/controller-runtime/pkg/runtime/scheme: module sigs.k8s.io/controller-runtime@latest found (v0.14.1), but does not contain package sigs.k8s.io/controller-runtime/pkg/runtime/scheme

看起来存在一些依赖问题,但我不确定如何解决它们。我尝试在 go.mod 中将 sigs.k8s.io/controller-runtime 设置为引用一个分支而不是最新版本,但似乎没有任何效果。

require (
	...
)

require (
	...
	sigs.k8s.io/cluster-api release-1.3 //indirect
)

我应该如何解决包依赖问题?

英文:

I would like to use the following function in my controller https://github.com/openshift/machine-api-operator/blob/05041eaab5a6b9e22dd26df421d8d51050c39072/pkg/controller/vsphere/util.go#L221
Thefore in my code I do the following import

package controllers

import (
	"context"

	vsphere "github.com/openshift/machine-api-operator/pkg/controller"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/types"
	"sigs.k8s.io/controller-runtime/pkg/client"
)

However, when I do go mod tidy, I get the following error:


bitbucket.bit.admin.ch/BOSC/bosc-drs-vm-group-controller/controllers imports
        github.com/openshift/machine-api-operator/pkg/controller imports
        github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck imports
        sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1: module sigs.k8s.io/cluster-api@latest found (v1.3.2), but does not contain package sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1
bitbucket.bit.admin.ch/BOSC/bosc-drs-vm-group-controller/controllers imports
        github.com/openshift/machine-api-operator/pkg/controller imports
        github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck imports
        github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1 imports
        sigs.k8s.io/controller-runtime/pkg/runtime/scheme: module sigs.k8s.io/controller-runtime@latest found (v0.14.1), but does not contain package sigs.k8s.io/controller-runtime/pkg/runtime/scheme

It seems that there are some dependencies issues, however I am not sure how to solve them. I tried in go.mod to set sigs.k8s.io/controller-runtime to reference a branch and not to latest, but it doesn't seem that it has any effect.


require (
	...
)

require (
	...
	sigs.k8s.io/cluster-api release-1.3 //indirect
	
)

How am I suppose to solve package dependencies issues?

答案1

得分: 2

这样可以:

go get github.com/openshift/machine-api-operator/pkg/controller/vsphere@master

该软件包在最新版本中不可用。

英文:

This works:

go get github.com/openshift/machine-api-operator/pkg/controller/vsphere@master

That package is not available in @latest release.

huangapple
  • 本文由 发表于 2023年1月12日 23:03:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75098362.html
匿名

发表评论

匿名网友

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

确定