I am trying to return two values (result and error) from a method but I get this
cannot use err (type error) as type goreq.Error in return argument
my code
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()
returns type error, not goreq.Error
. Change your second return type to error
instead of goreq.Error
.