1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-06 03:00:24 +08:00

reduce unsafe

This commit is contained in:
源文雨
2023-10-11 18:00:46 +09:00
parent 64f912e856
commit 58b8e7a98c
8 changed files with 19 additions and 29 deletions

View File

@@ -4,7 +4,6 @@ package nano
import (
"io"
"unsafe"
"github.com/pkg/errors"
)
@@ -18,7 +17,7 @@ func (bot *Bot) patchOpenAPIofChannel(ep string, body io.Reader) (*Channel, erro
if err != nil {
err = errors.Wrap(err, getCallerFuncName())
}
return (*Channel)(unsafe.Add(unsafe.Pointer(resp), unsafe.Sizeof(CodeMessageBase{}))), err
return &resp.Channel, err
}
func (bot *Bot) patchOpenAPIofGuildRolePatch(ep string, body io.Reader) (*GuildRolePatch, error) {
@@ -30,5 +29,5 @@ func (bot *Bot) patchOpenAPIofGuildRolePatch(ep string, body io.Reader) (*GuildR
if err != nil {
err = errors.Wrap(err, getCallerFuncName())
}
return (*GuildRolePatch)(unsafe.Add(unsafe.Pointer(resp), unsafe.Sizeof(CodeMessageBase{}))), err
return &resp.GuildRolePatch, err
}