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

import github.com/IBM/sarama error #1630

Open
wubonetcn opened this issue May 6, 2024 · 5 comments
Open

import github.com/IBM/sarama error #1630

wubonetcn opened this issue May 6, 2024 · 5 comments

Comments

@wubonetcn
Copy link

wubonetcn commented May 6, 2024

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

@wubonetcn
Copy link
Author

Is anyone concerned about the fix?

@fiurthorn
Copy link

fiurthorn commented May 9, 2024

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

@wubonetcn
Copy link
Author

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.

@ldez
Copy link
Contributor

ldez commented May 10, 2024

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

@wubonetcn
Copy link
Author

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

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

3 participants