Open
Description
The following program sample.go
triggers an unexpected result
package main
import (
"fmt"
"github.com/traefik/yaegi/interp"
)
var script = `package main
import (
"fmt"
)
func main() {
fmt.Println("hello there")
}
`
func main() {
i := interp.New(interp.Options{})
_, err := i.Eval(script)
if err != nil {
fmt.Println("Error:", err)
}
}
Expected result
$ env GOPATH=~/go/ go run main.go
// hello there
Got
$ env GOPATH=~/go/ go run main.go
// Error: 4:2: import "fmt" error: unable to find source related to: "fmt". Either the GOPATH environment variable, or the Interpreter.Options.GoPath needs to be set
Yaegi Version
v0.15.0
Additional Notes
Yaegi states that the GOPATH
environment variable is used for finding packages, except it never is. This only seems to work for the Yaegi binary, which explicitly passes it to the interpreter options.