3
0
Fork 0

FIX: nil pointer exception

This commit is contained in:
Thomas van Weert 2023-02-16 21:11:58 +01:00
parent 9edcb83fc4
commit ca59904eb8
3 changed files with 16 additions and 39 deletions

View file

@ -24,11 +24,19 @@ func CanServer(server string) bool {
}
func HasServer(publicKey string) (bool, *objects.Server) {
val, ok := servers.Load(publicKey)
return ok, val.(*objects.Server)
val, _ := servers.Load(publicKey)
if val == nil {
return false, nil
}
return true, val.(*objects.Server)
}
func RemoveServer(session string) *objects.Server {
val, _ := servers.LoadAndDelete(session)
if val == nil {
return nil
}
return val.(*objects.Server)
}