traefik / yaegi

Yaegi is Another Elegant Go Interpreter

Home Page:https://pkg.go.dev/github.com/traefik/yaegi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to use golang.org/x/oauth2 library

zetaab opened this issue · comments

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?

with // yaegi:tags purego

the response is same than in #1464 (comment) so this might be duplicate

seems that issue exist in master as well