golang / dep

Go dependency management tool experiment (deprecated)
https://golang.github.io/dep/
BSD 3-Clause "New" or "Revised" License
12.86k stars 1.05k forks source link

Same dependency in different vendor paths cannot be substituted for each other #2162

Closed AyushG3112 closed 3 years ago

AyushG3112 commented 5 years ago

go version: go version go1.12.5 linux/amd64 dep version: v0.5.3

I have 2 projects, mainProject and commonModules. mainProject uses commonModules for stuff like common interfaces and like. Using dep, it does not allow me to useinterfaces from commonModules in mainProject if the interface recieves a vendor type as parameter

// 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
}

Now, when I try to invoke MyMiddleware with &MyRequest{}, and try to build I get the error:

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
dlennardshipt commented 4 years ago

I'm also running into this issue

go 1.12.6 on darwin/amd64 dep v0.5.3

dlennardshipt commented 4 years ago

I ended up just deleting the vendor/ dir and the Gopkg.* files and rerunning dep init. This cleaned everything up.

mvdan commented 3 years ago

Dep was officially deprecated earlier this year, and the proposal to archive this repository was accepted. As such, I'm closing outstanding issues before archiving the repository. For any further comments, please use the proposal thread on the Go issue tracker. Thanks!