sgo icon indicating copy to clipboard operation
sgo copied to clipboard

Packages A and B both importing C use different C instances if you don't import C too.

Open tcard opened this issue 8 years ago • 0 comments

Example: both net/http and github.com/gorilla/websocket use net/url, but if you try do to this:

_ = &websocket.Dialer{
    Proxy: http.ProxyFromEnvironment,
}

you get this:

cannot use http.ProxyFromEnvironment (value of type func(req *net/http.Request) (*net/url.URL \ ?error)) as func(req *net/http.Request) (*net/url.URL \ ?error) value in struct literal

because SGo believes that net/url.URL is a different type in both signatures.

If you import net/url as well, it does work. So doing import _ "net/url" is a workaround.

tcard avatar Jul 28 '16 20:07 tcard