On Thu, Aug 30, 2018 at 12:09 PM Eric Raymond <[email protected]> wrote:
>
>
>>
>> If Event is your interface and EventImpl is your struct, what you need
>> is a map[string]Event, not map[string]*Event. Make sure you put
>> &EvenImpl{} to your slices and maps, not EventImpl{}
>>
>
> Here'a what is confusing me. Yes, I can write
>
> _mark_to_object map[string]Event
>
>
> and
>
> b.repo._mark_to_object[mark] = b
>
> for b a pointer to Blob, with Blob satisfying Event. This compiles without
> error.
>
> But what actually happens here? Is the new value a pointer to the same Blob
> instance that is in the main list, or does the code dereference b and put a
> *copy* of the blob in the map? The first behavior (reference) is what I want.
If b is an interface to a *Blob, what's stored in the slice is {Type:
*Blob, Value: pointer to the object}. A copy of this interface value
is also in the map. So you have two copies of the interface value,
both pointing to the same Blob object.
>
> --
> 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].
> For more options, visit https://groups.google.com/d/optout.
--
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].
For more options, visit https://groups.google.com/d/optout.