refactor: simplify nil check and fix handler validation

- Simplify IsNil() method by directly returning the nil check result
- Remove redundant nil check for handlers slice and fix indentation
This commit is contained in:
ideaa
2025-09-29 10:14:07 +08:00
parent b8ff6aef3c
commit 5dfa5f4f72
2 changed files with 6 additions and 10 deletions

View File

@@ -33,11 +33,7 @@ func (v *Value) Raw() any {
}
func (v *Value) IsNil() bool {
if v.data == nil {
return true
}
return false
return v.data == nil
}
func (v *Value) String() string {

View File

@@ -43,11 +43,11 @@ func Dispatcher(c *Client, request string) {
c.LastHeartbeatTime = t
}
handlers := InitManager().Handlers(req.Action)
if handlers == nil || len(handlers) == 0 {
c.SendActionMsg(&Action{Action: req.Action, Code: -1005, Msg: "request not supported"})
return
}
handlers := InitManager().Handlers(req.Action)
if len(handlers) == 0 {
c.SendActionMsg(&Action{Action: req.Action, Code: -1005, Msg: "request not supported"})
return
}
ctx := &Context{
Id: req.Id,