FIX: nil pointer exception
This commit is contained in:
parent
9edcb83fc4
commit
ca59904eb8
3 changed files with 16 additions and 39 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Reference in a new issue