traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
6.82k stars 342 forks source link

Howto assign a variable or value to yaegi? #1542

Open andig opened 1 year ago

andig commented 1 year ago

Proposal

First, please excuse me for asking here. https://community.traefik.io/c/yaegi seems a dead link and the community page doesn't have a yaegi section. Please close if inappropriate.

Background

I'd like to

a := "foo"
interp.Set("pkg.Vars.B", a)

instead of

interp.Eval("pkg.Vars.B := \"foo\"")

which requires individual handling per type. Set could follow Go's assignability rules.

Workarounds

Use Eval()