I'm implementing some thread safe data structures type Set struct { m map[string]int mux sync.Mutex }
func New() *Set { return &Set{m: make(map[string]int)} } In my Diff function i need to pass an array of sets to do a diff on another set func (set *Set) DiffS(sets []Set) *Set { set.mux.Lock() defer set.mux.Unlock() dup := duplicateMap(set.m) for i := 0; i < len(sets); i++ { for _, key := range sets[i].Elems() { delete(dup, key) } } return &Set{m: dup} } Code works fine, i ve written a unit test like this func TestSet_Diff(t *testing.T) { set1 := New() set2 := New() set3 := New() set1.Add([]string{"a", "b", "c", "d"}) set2.Add([]string{"c"}) set3.Add([]string{"a", "b"}) el := set1.Diff([]Set{*set2, *set3}) testsuite.ContainsElements(t, []string{"d"}, el) } This Unit Test passes fine But when i run the vet command with go vet ./... I get the following error internal\types\set\set_test.go:41: literal copies lock value from *set2: set .Set contains sync.Mutex internal\types\set\set_test.go:41: literal copies lock value from *set3: set .Set contains sync.Mutex What is the ideal solution for this? -- 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.