On Tue, Apr 18, 2017 at 2:13 PM, st ov <so.qu...@gmail.com> wrote:
> I read everything is pass-by-value in Go, is that correct?
> What does it encompass? Are there any exceptions?

There are no exceptions.  But it does require a clear understanding of
what Go means by a value.

> Does that mean the following:
>
> int passes full integer byte value
> float64 passes full float byte value
> string passes full string []byte value

Not really, a string passes a pointer (to an immutable []byte) and a length.

> slice passes pointer value to slice in memory

Not really, a slice passes a pointer to a backing array, a length, and
a capacity.

> map passes pointer value to map in memory
> func passes pointer value to func in memory
> interface passes pointer value to interface object in memory

Almost, an interface passes a pointer to a method table and a pointer value.

See https://research.swtch.com/godata .

Ian

-- 
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