How to fix this problem about datatype of this function.
Firstly, I'm new to Golang and am trying to learn it with some practice. I created a function to handle a request/GET http response.
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
}
The error warning.
cannot assign []byte to data (type byte) in multiple assignment
I just want the function to return raw data from API response