不能使用go dep替换不同供应商路径中的相同依赖项

时间:2019-05-14 08:38:51

标签: go

转到版本:转到版本go1.12.5 linux / amd64

dep版本:v0.5.3

我有2个项目,mainProjectcommonModulesmainProject使用commonModules处理诸如通用接口之类的东西。使用dep,如果该接口将供应商类型作为参数,则不允许我使用commonModulesmainProject中的接口

// mainProject
package requesttypes

import "github.com/aws/aws-lambda-go/events"

type MyRequest struct {
}

// BuildFromRequest populates the packet from the API request
func (s *MyRequest) BuildFromRequest(e events.APIGatewayProxyRequest) error {
    return nil
}

// MyMiddleware for API
package processors

import "commonModules/interfaces"
import "github.com/aws/aws-lambda-go/events"

func MyMiddleware(e events.APIGatewayProxyRequest,
    req interfaces.RequestWithBodies)  {
    // my logic
    return
}
// commonModules
package interfaces

import "github.com/aws/aws-lambda-go/events"

type RequestWithBodies interface {
    BuildFromRequest(events.APIGatewayProxyRequest) error
}

现在,当我尝试使用MyMiddleware调用&MyRequest{}并尝试构建时,出现错误:

cannot use request (type *requesttypes.MyRequest) as type interfaces.RequestWithBodies in argument to processors.MyMiddleware:
    *requesttypes.MyRequest does not implement interfaces.RequestWithBodies (wrong type for BuildFromRequest method)
        have BuildFromRequest("mainProject/vendor/github.com/aws/aws-lambda-go/events".APIGatewayProxyRequest) error
        want BuildFromRequest("commonModules/vendor/github.com/aws/aws-lambda-go/events".APIGatewayProxyRequest) error

有关如何解决此问题的任何帮助?由于我正在使用的供应商库的限制,我无法使用go get

编辑:

确切地说,我的问题是:

如果使用相同的库,则应该没有错误。那么我该如何解决呢?发生这种情况仅是因为dep将供应商依存关系放到了供应商文件夹中,但是在两种情况下,依存关系都是相同的。

0 个答案:

没有答案
相关问题