To expand on what Tamás said ... There is really nothing that is not safe 
to transport in a channel. But there are some considerations. 

For example if you transport an *http.**Response* then you will be making a 
copy on the way in and out of the channel. So that *may *not be safe, but 
it has nothing to do with channels, just that some objects are not safe to 
copy. If your value is not safe to copy, then use pointers in your 
channel.  

Another thing to consider is concurrent access. If you send a pointer to an 
object over a channel, but then continue to access is from the sending 
goroutine, you may be creating a race. Even if you pass an object by value, 
so it gets copied, you still need to make sure it does not *contain *any 
pointers, maps, slices, ect, before accessing the original and the copy 
concurrently, since go copy is shallow. 

Hope this helps.

On Tuesday, October 2, 2018 at 1:49:58 AM UTC-4, Patrik Iselind wrote:
>
> Hi,
>
> I came up with a question i cannot answer. Hopefully you guys can clarify 
> things for me.
>
> If i've made a HTTP request and i get the response. I don't touch the body 
> or anything at this point. Would that response be safe to transport in a 
> channel? Having the other end process the response.
>
> A bit more general question; what's not safe to transport in a channel?
>
> Regards,
> Patrik
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to