I don't see anything fundamentally wrong with using a *sync.Mutex as long 
as users always use New(). It allows Set to be passed by value, which is 
nice. 

But if you keep the mutex as a non pointer, then you probably want to pass 
a slice of set pointers:
func (set *Set) Diff(sets []*Set) *Set
This avoids copying the mutex when you create your slice, so the test line 
becomes:
set1.Diff([]*Set{set2, set3})

Of course your original Diff code is technically ok. The problem is in 
creating a []Set from individual Set objects without violating the mutex 
copy rules is difficult, and would require a bunch of code. 


On Friday, August 10, 2018 at 3:02:57 AM UTC-4, Kasun Vithanage wrote:
>
> I want an slice of sets
>
> On Tuesday, August 7, 2018 at 6:32:25 PM UTC+5:30, Dave Cheney wrote:
>>
>> Pass a pointer, *Set into your Diff method. 
>
>

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