diff --git a/storage/channel.go b/storage/channel.go index a946c714..c2858dfb 100644 --- a/storage/channel.go +++ b/storage/channel.go @@ -93,8 +93,9 @@ func (c *ChannelStore) SetUsers(users []string, server, channel string) { c.users[server] = make(map[string][]*ChannelStoreUser) } - for _, nick := range users { - c.users[server][channel] = append(c.users[server][channel], NewChannelStoreUser(nick)) + c.users[server][channel] = make([]*ChannelStoreUser, len(users)) + for i, nick := range users { + c.users[server][channel][i] = NewChannelStoreUser(nick) } c.userLock.Unlock() diff --git a/storage/channel_test.go b/storage/channel_test.go index 822490cf..f35a486f 100644 --- a/storage/channel_test.go +++ b/storage/channel_test.go @@ -11,6 +11,8 @@ func TestGetSetUsers(t *testing.T) { users := []string{"a", "b"} channelStore.SetUsers(users, "srv", "#chan") assert.Equal(t, users, channelStore.GetUsers("srv", "#chan")) + channelStore.SetUsers(users, "srv", "#chan") + assert.Equal(t, users, channelStore.GetUsers("srv", "#chan")) } func TestAddRemoveUser(t *testing.T) {