I try to pass dynamic slic to this jsonstr slice
var catlist []string
var jsonStr = []byte(`{"categoryList":`+catlist+`}`)
But i'm getting this error
invalid operation: "{\"categoryList\":" + catlist (mismatched types string and []string)
How can I fix this error
data := make(map[string]interface{})
data["categoryList"] = catlist
bytearray, err := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(bytearray))
You are concating string
and []string
!! this is impossible! You must use json
package: Package json