Reputation: 894
I am writing an application in Go that uses a Logger object type.
In it I use another application that uses the same logger object type:
App1:
import "gitlab.sio.com/go/zlog"
var logger = zlog.New(append(opts,
zlog.App(c.Name, typ, version),
zlog.Env(c.Environment),
)...)
....
router.GET("/get", GetHandler(logger))
....
func GetHandler(logger *zlog.Logger){
....
mdl, _ := security.New(*logger)
....
}
App2(security.New from security lib):
package security
import "gitlab.sio.com/go/zlog"
Middleware struct {
log zlog.Logger
}
func New(log zlog.Logger){
...
mdw := Middleware{}
mdw.log = log
}
The error what I'm getting at line
mdl, _ := security.New(*logger)
is:
cannot use *logger (type "gitlab.sio.com/go/furtif/vendor/gitlab.sio.com/go/zlog".Logger) as type "gitlab.sio.com/go/security/vendor/gitlab.sio.com/go/zlog".Logger in argument to security.New
Upvotes: 1
Views: 9218
Reputation: 843
This error happened to me because I had a type declared more than once across the same package.
Upvotes: -1
Reputation: 353
The issue is due to the same library imported in two different vendor folders. If you are trying to use the application 2 only as a library, removing the vendor folder in the application 2 will solve this issue.
Upvotes: 3
Reputation: 7477
You need to fix your import statements to properly point the import types from where they should belong to. Read the error message.
Upvotes: 1