Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoggerMock can not use as the type ctxd.Logger #7

Open
dohernandez opened this issue Nov 13, 2021 · 1 comment
Open

LoggerMock can not use as the type ctxd.Logger #7

dohernandez opened this issue Nov 13, 2021 · 1 comment

Comments

@dohernandez
Copy link

When I tried to use an instance of LoggerMock as a ctxd.Logger, I get the following error:

Cannot use 'l' (type LoggerMock) as the type ctxd.Logger Type does not implement 'ctxd.Logger' as the 'Debug' method has a pointer receiver
import "github.com/bool64/ctxd"

type Server struct {
    log      ctxd.Logger
}

func NewServer(log ctxd.Logger) *Server {
    return &Server{log: log}
}

l := ctxd.LoggerMock{}

s := NewServer(l)
@vearutop
Copy link
Member

LoggerMock is intended to be used by pointer, please try:

import "github.com/bool64/ctxd"

type Server struct {
    log      ctxd.Logger
}

func NewServer(log ctxd.Logger) *Server {
    return &Server{log: log}
}

l := ctxd.LoggerMock{}

s := NewServer(&l)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants