我试图从方法返回两个值(结果和错误),但我得到了这个
cannot use err (type error) as type goreq.Error in return argument
我的代码
package components
import (
goreq "github.com/franela/goreq"
"time"
)
var UserAgent string = "..."
func Get(url string) (*goreq.Response, goreq.Error) {
goreq.SetConnectTimeout(15 * time.Second)
res, err := goreq.Request{
Uri: url,
UserAgent: UserAgent,
Timeout: 5 * time.Second,
}.Do()
return res, err
}