machinery icon indicating copy to clipboard operation
machinery copied to clipboard

compile error: impossible type assertion

Open mzychaco opened this issue 2 years ago • 2 comments

I got an error while I tring to compile my project with machinery/v1 Here is the log:


external/com_google_cloud_go_pubsub/message.go:42:42: impossible type assertion:
        *psAckHandler does not implement "cloud.google.com/go/internal/pubsub".AckHandler (missing OnAckWithResult method)
external/com_google_cloud_go_pubsub/message.go:70:27: cannot use ackh (type *psAckHandler) as type "cloud.google.com/go/internal/pubsub".AckHandler in argument to "cloud.google.com/go/internal/pubsub".NewMessage:
        *psAckHandler does not implement "cloud.google.com/go/internal/pubsub".AckHandler (missing OnAckWithResult method)
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/compile: exit status 2
Target //workflow/cmd:workflow failed to build

And then, I found that Machinery depends on cloud.google.com/[email protected], but my project depends on v0.105.0. The different between this two version is about a interface in cloud.google.com/go/internal/pubsub/message.go

type AckHandler interface {

        // both declare in  v0.76.0 and v0.105.0
	OnAck() 
	OnNack()

        // only declare in v0.105.0
	OnAckWithResult() *AckResult
	OnNackWithResult() *AckResult
}

What should I do with this error? Beg for reply, thanks a lot

mzychaco avatar Dec 13 '22 12:12 mzychaco

you can replace broken dependency on go mod ... project has not been updated for a long time

replace (
	cloud.google.com/go/pubsub => cloud.google.com/go/pubsub v1.9.0 // bug on machinery
)

kabelsea avatar Dec 27 '22 08:12 kabelsea

Thanks @kabelsea that fixed my issue as well using that package in GoLand IDE

mrz1836 avatar Feb 02 '23 17:02 mrz1836