user3773847
user3773847

Reputation: 11

How to get underlying variable from Go custom type

I'm trying to abstract the use of gorequest by only importing my own libraries into the main code and using a helper to download a page using gorequest. The .End() method returns a gorequest.Response, a string (containing the body) and a slice of errors if present.

The gorequest.Response it's just an http.Response declared as type Response *http.Response

In order to prevent importing the library into other go files, how could I get the underlying http.Response from the gorequest.Response type?

Upvotes: 0

Views: 47

Answers (1)

Patrick D'appollonio
Patrick D'appollonio

Reputation: 2762

It looks to me that gorequest.Response is just a pointer to http.Response so you could do something like:

var response http.Response
response = *gorequest.Response

And that should help you pass it as a pointer.

Upvotes: 1

Related Questions