string function for user
Syfaro syfaro@foxpaw.in
Fri, 31 Jul 2015 03:22:01 -0400
1 files changed,
16 insertions(+),
0 deletions(-)
jump to
M
types.go
→
types.go
@@ -26,6 +26,22 @@ LastName string `json:"last_name"`
UserName string `json:"username"` } +// String displays a simple text version of a user. +// It is normally a user's username, +// but falls back to a first/last name as available. +func (u *User) String() string { + if u.UserName != "" { + return u.UserName + } + + name := u.FirstName + if u.LastName != "" { + name += " " + u.LastName + } + + return name +} + // GroupChat is a group chat, and not currently in use. type GroupChat struct { ID int `json:"id"`