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

unable to use golang.org/x/oauth2 library #1588

Open zetaab opened 10 months ago

zetaab commented 10 months ago

The following program sample.go triggers an unexpected result

package main

import (
    "fmt"

    "golang.org/x/oauth2"
)

type config struct {
    provider *oauth2.Config
}

func main() {
    conf := config{}
    fmt.Printf("%+v\n", conf)
}

Expected result

% go run main.go
{provider:<nil>}

Got

% yaegi ./main.go 
run: ./main.go:6:2: import "golang.org/x/oauth2" error: /go/src/github.com/myproject/myproject/vendor/golang.org/x/oauth2/oauth2.go:21:2: import "golang.org/x/oauth2/internal" error: /go/src/github.com/myproject/myproject/vendor/golang.org/x/oauth2/internal/client_appengine.go:9:8: import "google.golang.org/appengine/urlfetch" error: /go/src/github.com/myproject/myproject/vendor/google.golang.org/appengine/urlfetch/urlfetch.go:20:2: import "github.com/golang/protobuf/proto" error: /go/src/github.com/myproject/myproject/vendor/github.com/golang/protobuf/proto/buffer.go:11:2: import "google.golang.org/protobuf/encoding/prototext" error: /go/src/github.com/myproject/myproject/vendor/google.golang.org/protobuf/encoding/prototext/decode.go:11:2: import "google.golang.org/protobuf/internal/encoding/messageset" error: /go/src/github.com/myproject/myproject/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go:13:2: import "google.golang.org/protobuf/reflect/protoreflect" error: /go/src/github.com/myproject/myproject/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go:11:2: import "unsafe" error: unable to find source related to: "unsafe"

Yaegi Version

0.15.1

Additional Notes

just thinking what is the point here to not allow running unsafe stuff in traefik. Or even make it somehow possible? About half of internet dependencies contains unsafe package.

like in this case I am using package version: golang.org/x/oauth2 v0.11.0

However, if I force that to OLDER version it will work: golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1

but in my opinion this does not make sense. We need to find some old version which will work, and after that we cannot even patch security issues in packages?

zetaab commented 10 months ago

with // yaegi:tags purego

the response is same than in https://github.com/traefik/yaegi/issues/1464#issuecomment-1468457479 so this might be duplicate

seems that issue exist in master as well