duansai1314 2019-05-10 16:54
浏览 79

在不同的go项目中共享供应商库出现问题

I just started to do some "serious" code in GoLang and I'm trying to use a custom utils library I built with some common features in a new project. One of my common library methods returns an instance of the AWS SDK Session struct that I'm trying to use on my outer project.

I'm using dep for my project dependencies and I'm importing in both (the project and the library) the SDK the same way:

import "github.com/aws/aws-sdk-go/aws/session"

However the compiler complains that the Session struct I'm returning in my library method is different from the Session interface I need in my project.

sess, err := myawsutils.NewSession()
s3Client := s3.New(sess)
        *session.Session does not implement "gitlab.com/xyz/storage-sls.xyz.com/api/go/vendor/github.com/aws/aws-sdk-go/aws/client".ConfigProvider (wrong type for ClientConfig method)
                have ClientConfig(string, ...*"gitlab.com/xyz/golang-sls-utils/vendor/github.com/aws/aws-sdk-go/aws".Config) "gitlab.com/xyz/golang-sls-utils/vendor/github.com/aws/aws-sdk-go/aws/client".Config
                want ClientConfig(string, ...*"gitlab.com/xyz/storage-sls.xyz.com/api/go/vendor/github.com/aws/aws-sdk-go/aws".Config) "gitlab.com/xyz/storage-sls.xyz.com/api/go/vendor/github.com/aws/aws-sdk-go/aws/client".Config

Ideally I would like to share references to the same structures along multiple projects. I'm definitely missing some basic core concept of the way the language works and compiles. Appreciate any help. Thanks!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python时间序列如何拟合疏系数模型
    • ¥15 求学软件的前人们指明方向🥺
    • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
    • ¥15 MCNP里如何定义多个源?
    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 STM32驱动继电器