sgo
sgo copied to clipboard
Packages A and B both importing C use different C instances if you don't import C too.
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.