From 8987bae9f2ecdde6b7928c876a2b910b55e56653 Mon Sep 17 00:00:00 2001 From: harry <541573560@qq.com> Date: Fri, 19 Apr 2024 13:50:04 +0800 Subject: [PATCH] feat: fix GetPaginationUsers error: "response data format is incorrect" (#106) --- casdoorsdk/user.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/casdoorsdk/user.go b/casdoorsdk/user.go index e0bf131..c3a419f 100644 --- a/casdoorsdk/user.go +++ b/casdoorsdk/user.go @@ -275,8 +275,14 @@ func (c *Client) GetPaginationUsers(p int, pageSize int, queryMap map[string]str return nil, 0, err } - users, ok := response.Data.([]*User) - if !ok { + dataBytes, err := json.Marshal(response.Data) + if err != nil { + return nil, 0, err + } + + var users []*User + err = json.Unmarshal(dataBytes, &users) + if err != nil { return nil, 0, errors.New("response data format is incorrect") }