Skip to content

Commit 0d4f911

Browse files
committed
handle api with SafeGo
1 parent 6c34895 commit 0d4f911

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

service/bot/remote.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/Mrs4s/MiraiGo/client"
10+
"github.com/ProtobufBot/Go-Mirai-Client/pkg/util"
1011
"github.com/ProtobufBot/Go-Mirai-Client/proto_gen/onebot"
1112
"github.com/golang/protobuf/proto"
1213
"github.com/gorilla/websocket"
@@ -100,7 +101,7 @@ func ListenApi(cli *client.QQClient) {
100101
continue
101102
}
102103

103-
go func() {
104+
util.SafeGo(func() {
104105
resp := handleApiFrame(cli, &req)
105106
respBytes, err := resp.Marshal()
106107
if err != nil {
@@ -110,7 +111,7 @@ func ListenApi(cli *client.QQClient) {
110111
if err != nil {
111112
log.Errorf("发送ApiResp错误 %v", err)
112113
}
113-
}()
114+
})
114115
}
115116
}
116117

0 commit comments

Comments
 (0)