Thank you!
On Saturday, 1 August 2020 19:48:50 UTC+2, Brian Candler wrote:
>
> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/55db7788-e959-4970-8742-e9e930240f0bo%40googlegroups.com.