traefik/yaegi

import github.com/IBM/sarama error

wubonetcn opened this issue · 5 comments

The following program sample.go triggers an unexpected result

I ran the following file and got an error.
https://github.com/IBM/sarama/tree/main/examples/consumergroup/main.go

└─$ yaegi                                       
> import "github.com/klauspost/compress/flate"
1:21: import "github.com/klauspost/compress/flate" error: /home/kali/code/src/github.com/klauspost/compress/flate/stateless.go:193:43: cannot use type int16 as type int32 in struct literal
>

Expected result

┌──(kali㉿kali)-[~/…/IBM/sarama/examples/consumergroup]
└─$ go run main.go
panic: no Kafka bootstrap brokers defined, please set the -brokers flag

goroutine 1 [running]:
main.init.0()
        /home/kali/code/src/github.com/IBM/sarama/examples/consumergroup/main.go:40 +0x32c
exit status 2

Got

(kali㉿kali)-[~/…/IBM/sarama/examples/consumergroup]
└─$ yaegi  -syscall -unsafe -unrestricted main.go
run: main.go:15:2: import "github.com/IBM/sarama" error: /home/kali/code/src/github.com/IBM/sarama/compress.go:9:2: import "github.com/klauspost/compress/gzip" error: /home/kali/code/src/github.com/IBM/sarama/examples/consumergroup/vendor/github.com/klauspost/compress/gzip/gunzip.go:17:2: import "github.com/klauspost/compress/flate" error: /home/kali/code/src/github.com/IBM/sarama/examples/consumergroup/vendor/github.com/klauspost/compress/flate/stateless.go:193:43: cannot use type int16 as type int32 in struct literal

Yaegi Version

v0.16.1

Additional Notes

No response

Is anyone concerned about the fix?

I think you have to use yaegi extract to make your stucts/interfaces accessable by the interpreter.

I think you have to use yaegi extract to make your stucts/interfaces accessable by the interpreter.

Thank you for your answer, I'm working on a trafik plugin, I don't know how to turn on yaegi extract in trafik, and I do have github.com/klauspost/compress/flate in my GOAPTH. So I feel like it's really a trafik bug.

So I feel like it's really a trafik bug.

It's not a Traefik bug: only yaegi handles the load of plugins.

I think your problem is the management of the dependencies of your plugins.

https://github.com/traefik/plugindemo?tab=readme-ov-file#tags-and-dependencies

klauspost

Thanks for your answer. I checked how I used it according to your guidance, and it still didn't work, I called the plugin locally. I found a similar issue in a past issue, it looks like github.com/klauspost/compress updated the code, and yaegi can't parse it again.
#865