In Go, everything is passed by value: that is, assignments and function 
calls make a copy of the value.

However, some types are effectively structs which contain pointers embedded 
within them.  Strings, slices, maps, channels and interface values fall 
into this category.

string is roughly equivalent to:

struct {
    ptr *byte  // immutable
    len int
}

[]byte is roughly equivalent to:

struct {
    buf *byte
    len int
    cap int
}

When you assign one of these values, or pass it as a parameter to a 
function, then the struct is copied by value - e.g. if the struct is 16 
bytes then you're copying 16 bytes - but both copies contain a pointer to 
the same underlying data (which could be larger or smaller).

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9f2f99a0-3aec-431d-b395-23d431ffcbf1o%40googlegroups.com.

Reply via email to