We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 559190d commit 76837c0Copy full SHA for 76837c0
gitea/user.go
@@ -5,6 +5,7 @@
5
package gitea
6
7
import (
8
+ "encoding/json"
9
"fmt"
10
)
11
@@ -17,6 +18,16 @@ type User struct {
17
18
AvatarURL string `json:"avatar_url"`
19
}
20
21
+// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
22
+func (u User) MarshalJSON() ([]byte, error) {
23
+ // Re-declaring User to avoid recursion
24
+ type shadow User
25
+ return json.Marshal(struct {
26
+ shadow
27
+ CompatUserName string `json:"username"`
28
+ }{shadow(u), u.UserName})
29
+}
30
+
31
// GetUserInfo get user info by user's name
32
func (c *Client) GetUserInfo(user string) (*User, error) {
33
u := new(User)
0 commit comments