avoid concurrent map iteration and map write

This commit is contained in:
aoife cassidy 2025-11-01 21:40:57 +01:00
parent a2ffa6b706
commit 51e55d2428
No known key found for this signature in database
GPG Key ID: 7184AC1C9835CE48

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"maps"
"net"
"os"
"slices"
@ -214,12 +215,7 @@ func (m model) View() (s string) {
}
s += fmt.Sprintf("%d user%s connected:\n", numUsers, plural)
keys := make([]string, 0, numUsers)
for k := range m.users {
keys = append(keys, k)
}
slices.Sort(keys)
for _, nick := range keys {
for _, nick := range slices.Sorted(maps.Keys(m.users)) {
user := m.users[nick]
status := " "
nickStyled := styleInactive.Render(nick)