I cloned a project which uses go-kit, when I try to compile the project, I get an compilation error which is something like
./main.go:124: cannot use makePostEndpoint(svc) (type endpoint.Endpoint) as type "github.com/go-kit/kit/transport/http".DecodeRequestFunc in argument to "github.com/go-k
it/kit/transport/http".NewServer
The snippet of code is as below
func main() {
ctx := context.Background()
svc := cayleyService{}
postHandler := httptransport.NewServer(
ctx,
makePostEndpoint(svc),
decodePostRequest,
encodeResponse,
)
}
func makeGetEndpoint(svc CayleyService) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(getRequest)
v, err := svc.Get(req.Qu)
if err != nil {
return getResponse{v, err.Error()}, nil
}
return getResponse{v, ""}, nil
}
}
I have version 1.8.1 of golang installed.
I found the issue. There is a newer version of go kit in which the signature of the NewServer has changed. Context has been removed and hence. I just had to remove the ctx and everything compiled.