I dont understand what the error means but I think it is getting confused between the package in absolute path and in the vendor path. How do I make it not confused?
# github.com/GoogleCloudPlatform/terraformer/providers/alicloud
providers/alicloud/dum.go:10:35: cannot use func literal (type func(*"github.com/aliyun/aliyun-oss-go-sdk/oss".Client) (interface {}, error)) as type func(*"github.com/terraform-providers/terraform-provider-alicloud/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss".Client) (interface {}, error) in argument to client.WithOssClient
Here is the minimum reproducible code
package dum
import (
oss "github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/terraform-providers/terraform-provider-alicloud/alicloud/connectivity"
)
func dum() error {
client := connectivity.AliyunClient{}
raw, err := client.WithOssClient(func(ossClient *oss.Client) (interface{}, error) {
return ossClient.ListBuckets()
})
if err != nil {
return err
}
println(raw)
return nil
}
The error means that the two types, although equivalent, because they live in separate packages, are treated as different. To make the code work, you can either import oss
from the github.com/terraform-providers/terraform-provider-alicloud/vendor/...
path. Or have your app vendor both connectivity
and oss
.
The compiler cannot replace "github.com/aliyun/aliyun-oss-go-sdk/oss".Client with github.com/terraform-providers/terraform-provider-alicloud/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss".Client, even they have the same name(but from different package).