multiple vendor path for same type

71 views
Skip to first unread message

Nobin Mathew

unread,
May 15, 2020, 1:04:40 PM5/15/20
to golang-nuts
Hi all,

I am almost new to golang, sorry if I am asking some silly question.

I am facing some compilation issue due to type conflict

**************************

+++ [0515 07:51:26] Building go targets for linux/amd64:
    test/e2e/e2e.test
# k8s.io/kubernetes/test/e2e/framework
test/e2e/framework/framework.go:239:44: cannot use config (type *"k8s.io/kubernetes/vendor/k8s.io/client-go/rest".Config) as type *"k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/vendor/k8s.io/client-go/rest".Config in argument to "k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1".NewForConfig
test/e2e/framework/framework_multus.go:14:3: cannot use "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta literal (type "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta) as type "k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta in field value
!!! [0515 07:51:30] Call tree:
!!! [0515 07:51:30]  1: /home/eccd/go/src/k8s.io/kubernetes/hack/lib/golang.sh:853 kube::golang::build_binaries_for_platform(...)
!!! [0515 07:51:30]  2: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0515 07:51:30] Call tree:
!!! [0515 07:51:30]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0515 07:51:30] Call tree:
!!! [0515 07:51:30]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:93: all] Error 1

***************************************

I Included a library 
"github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1"

in kubernetes (this is for some internal development, kubernetes guys wont like it :) )



if you look at line number 239:44 error, there is type conflict but it is actually pointing to same struct.
Expecting is

"k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/vendor/k8s.io/client-go/rest".Config"

but provided
"k8s.io/kubernetes/vendor/k8s.io/client-go/rest".Config"

But if you look at what is after "vendor", both are same i.e. "k8s.io/client-go/rest".Config"



How can I solve this problem. I any help or pointers will be helpful(any directions to read).


-Nobin

Ian Lance Taylor

unread,
May 15, 2020, 2:21:07 PM5/15/20
to Nobin Mathew, golang-nuts
In Go, types are distinguished by the import path used to find the type.

In this case, it looks like you have the same package at two different
positions in your source tree. Go will treat the types defined in
those two different packages as different types.

Ian
Reply all
Reply to author
Forward
0 new messages