The return type of your function is of type byte
, whereas the return type of ioutil.ReadAll
is []byte
. Those types do not match, where one is a byte and the other is a slice of bytes. Change the return type of data
to []byte
, assuming that is what you wanted in the first place.
func connect(url, token string) (data []byte) {
var bearer = "Bearer " + token
res, err := http.Get(url)
res.Header.Add("Authorization", bearer)
defer res.Body.Close()
data, _ := ioutil.ReadAll(res.Body)
return data
}