Open karelorigin opened 1 year ago
Yes, the GOPATH
environment variable is used by default for the command line executable (github.com/traefik/yaegi/cmd/yaegi
), but not by the library package (github.com/traefik/yaegi/interp
) that you use in your example. This is on purpose, for security reason when the interpreter is embedded in another host process and that we require the full control of the GOPATH, possibly fully separated from the default. We decided to make the management of GOPATH explicit, with an empty default.
You can still pass the GOPATH when creating the interpreter as in the following:
I := interp.New(interp.Options{GoPath: build.Default.GOPATH})
Could it be a good idea to change the error message as it's (almost) never applicable and thus not accurate?
@karelorigin yes you're right. I haven't noticed that the error message is inaccurate and needs to be changed. Thanks.
The following program
sample.go
triggers an unexpected resultExpected result
Got
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.