From 817482bedb66a498183897656d73b858957c831f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=B8=85?= <133814250@qq.com> Date: Thu, 9 May 2024 11:25:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=BD=9C=E5=9C=A8?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E8=B6=8A=E9=99=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/internal/library/dict/dict_option.go | 4 +++- server/internal/library/network/tcp/msg_parser.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/internal/library/dict/dict_option.go b/server/internal/library/dict/dict_option.go index bfebb12..b52070b 100644 --- a/server/internal/library/dict/dict_option.go +++ b/server/internal/library/dict/dict_option.go @@ -75,7 +75,9 @@ func GenHashOption(key interface{}, label string) *model.Option { tag := "default" if _, err := hash.Write(gconv.Bytes(label)); err == nil { index := int(hash.Sum32()) % len(strings) - tag = strings[index] + if index < len(strings) { + tag = strings[index] + } } return &model.Option{ Key: key, diff --git a/server/internal/library/network/tcp/msg_parser.go b/server/internal/library/network/tcp/msg_parser.go index 3df173f..d708800 100644 --- a/server/internal/library/network/tcp/msg_parser.go +++ b/server/internal/library/network/tcp/msg_parser.go @@ -89,7 +89,7 @@ func (m *MsgParser) RegisterRPCRouter(routers ...interface{}) (err error) { // RegisterInterceptor 注册拦截器 func (m *MsgParser) RegisterInterceptor(interceptors ...Interceptor) { - m.interceptors = append(interceptors, interceptors...) + m.interceptors = append(m.interceptors, interceptors...) } // Encoding 消息编码