无法将err(类型错误)用作返回参数中的类型goreq.error

无法将err(类型错误)用作返回参数中的类型goreq.error,go,Go,我试图从一个方法返回两个值(result和error),但我得到了这个结果 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.

我试图从一个方法返回两个值(result和error),但我得到了这个结果

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
}

Do()
。将第二个返回类型更改为
error
,而不是旁注中的
goreq.error

,您永远不应该返回特定的错误类型,只返回错误接口(正是出于这个原因)。