-
Notifications
You must be signed in to change notification settings - Fork 362
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
Can't use external libraries in the code: "unable to find source related to xxxx" #656
Comments
I tried to add the external library as you wrote: _ "github.com/tidwall/pretty" But I received the same error. |
The tooling for pre-compiling only works for shipping the standard library for now, and not for third-party libraries yet. Support for third-party libraries is on the roadmap in the short to mid term.
You are probably getting that error because yaegi does not support go modules yet. Do you still get the error if you make sure to have "github.com/tidwall/pretty" in your GOPATH (or vendored in) ? |
I checked, My GOATPH is: GOPATH=C:\Users\user1\go
I created a vendor folder and copy & paste the But I received the same error:
So currently yaegi doesn't support external libraries? |
? |
@g3rzi yaegi is unsupported and untested on windows, so you might be running into a problem just because you're on windows, and we cannot help you debug that. |
The problem exist also Linux. package main
import (
"github.com/containous/yaegi/interp"
"github.com/containous/yaegi/stdlib"
)
const payload = `
package main
import (
"fmt"
"github.com/tidwall/pretty"
)
func main(){
var example2 = "{\"name\": \"hello\"}"
result := pretty.Pretty([]byte(example2))
fmt.Println(string(result))
}
`
func main(){
i := interp.New(interp.Options{})
i.Use(stdlib.Symbols)
_, err := i.Eval(payload)
if err != nil {
panic(err)
}
} I go the following error:
Expected:
|
You need to specify the
|
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
no response after a long time. |
it's ok |
github.com/traefik/yaegi/issues/656#issuecomment-1449633582
* chore: update yaegi v0.16.1 and golangci-lint v1.61.0 * fix(ci): copy go vendor to gopath github.com/traefik/yaegi/issues/656#issuecomment-1449633582 * fix(ci): use gopath setup in step in advance * chore(ci): disable yaegi testing
I am trying to use Yaegi to run Golang code that contains 3rd party library called:
github.com/tidwall/pretty
You wrote here #469 that it is possible:
But I didn't understand how can I re-build the interpreter with a pre-compiled library?
Ho can I do it?
The following program
sample.go
triggers a panic:Expected result:
Got:
The text was updated successfully, but these errors were encountered: