From 2d11a7b95a90f411b48586c0e3e3a421c5a96bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E5=90=83=E7=82=B9=E8=8B=B9=E6=9E=9C?= <73388495+eatmoreapple@users.noreply.github.com> Date: Tue, 24 Jan 2023 21:17:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E7=85=A7=E5=BE=AE=E4=BF=A1=E7=9A=84?= =?UTF-8?q?=E6=8E=92=E5=88=97=E9=A1=BA=E5=BA=8F=E8=8E=B7=E5=8F=96=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E4=BA=BA=E5=88=97=E8=A1=A8=20(#213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- relations.go | 18 +++++++++--------- user.go | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/relations.go b/relations.go index 5bbd6fa..19762e0 100644 --- a/relations.go +++ b/relations.go @@ -9,7 +9,7 @@ import ( type Friend struct{ *User } // implement fmt.Stringer -func (f Friend) String() string { +func (f *Friend) String() string { return fmt.Sprintf("", f.NickName) } @@ -53,7 +53,7 @@ func (f Friends) Count() int { // First 获取第一个好友 func (f Friends) First() *Friend { if f.Count() > 0 { - return f[0] + return f.Sort()[0] } return nil } @@ -61,7 +61,7 @@ func (f Friends) First() *Friend { // Last 获取最后一个好友 func (f Friends) Last() *Friend { if f.Count() > 0 { - return f[f.Count()-1] + return f.Sort()[f.Count()-1] } return nil } @@ -155,7 +155,7 @@ func (f Friends) SendFile(file io.Reader, delay ...time.Duration) error { type Group struct{ *User } // implement fmt.Stringer -func (g Group) String() string { +func (g *Group) String() string { return fmt.Sprintf("", g.NickName) } @@ -238,7 +238,7 @@ func (g Groups) Count() int { // First 获取第一个群组 func (g Groups) First() *Group { if g.Count() > 0 { - return g[0] + return g.Sort()[0] } return nil } @@ -246,7 +246,7 @@ func (g Groups) First() *Group { // Last 获取最后一个群组 func (g Groups) Last() *Group { if g.Count() > 0 { - return g[g.Count()-1] + return g.Sort()[g.Count()-1] } return nil } @@ -340,7 +340,7 @@ func (g Groups) Uniq() Groups { // Mp 公众号对象 type Mp struct{ *User } -func (m Mp) String() string { +func (m *Mp) String() string { return fmt.Sprintf("", m.NickName) } @@ -355,7 +355,7 @@ func (m Mps) Count() int { // First 获取第一个 func (m Mps) First() *Mp { if m.Count() > 0 { - return m[0] + return m.Sort()[0] } return nil } @@ -363,7 +363,7 @@ func (m Mps) First() *Mp { // Last 获取最后一个 func (m Mps) Last() *Mp { if m.Count() > 0 { - return m[m.Count()-1] + return m.Sort()[m.Count()-1] } return nil } diff --git a/user.go b/user.go index 90957aa..45f233e 100644 --- a/user.go +++ b/user.go @@ -263,6 +263,7 @@ func (s *Self) Members(update ...bool) (Members, error) { return nil, err } } + s.members.Sort() return s.members, nil }