Fix crash #174 by duplicating curl handle

Wrap libcurl to bypass lack of covariance support
This commit is contained in:
Brendan Le Glaunec
2018-03-13 10:24:25 +01:00
committed by Brendan LE GLAUNEC
parent 6392dcd9a0
commit bcc8099f91
4 changed files with 25 additions and 4 deletions
+12
View File
@@ -10,4 +10,16 @@ type Curler interface {
Setopt(opt int, param interface{}) error
Perform() error
Getinfo(info curl.CurlInfo) (interface{}, error)
Duphandle() Curler
}
// Curl is a libcurl wrapper used to make the Curler interface work even though
// golang currently does not support covariance (see https://github.com/golang/go/issues/7512)
type Curl struct {
*curl.CURL
}
// Duphandle wraps curl.Duphandle
func (c *Curl) Duphandle() Curler {
return &Curl{c.CURL.Duphandle()}
}