Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Mar 23, 2024
1 parent c379bc6 commit 570bcb4
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --out-${NO_FUTURE}format line-number --timeout 3m0s
args: --out-${NO_FUTURE}format line-number --timeout 3m0s -p bugs -p error -p performance -D unused -D gosmopolitan

- name: Test
run: go test -v ./...

- name: Build
run: go build -v ./...
18 changes: 9 additions & 9 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (

// AccountInformation 自己账号相关的简单信息
type AccountInformation struct {
Mid int64 `json:"mid"` //我的mid
Uname string `json:"uname"` //我的昵称
Userid string `json:"userid"` //我的用户名
Sign string `json:"sign"` //我的签名
Birthday string `json:"birthday"` //我的生日
Sex string `json:"sex"` //我的性别
NickFree bool `json:"nick_free"` //false:设置过昵称 true:未设置昵称
Rank string `json:"rank"` //我的会员等级
Mid int64 `json:"mid"` // 我的mid
Uname string `json:"uname"` // 我的昵称
Userid string `json:"userid"` // 我的用户名
Sign string `json:"sign"` // 我的签名
Birthday string `json:"birthday"` // 我的生日
Sex string `json:"sex"` // 我的性别
NickFree bool `json:"nick_free"` // false:设置过昵称 true:未设置昵称
Rank string `json:"rank"` // 我的会员等级
}

// GetAccountInformation 获取我的信息 无参数
Expand All @@ -34,5 +34,5 @@ func (c *Client) GetAccountInformation() (*AccountInformation, error) {

err = json.Unmarshal(data, &accountInfo)

return &accountInfo, err
return &accountInfo, errors.WithStack(err)
}
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c *Client) GetCookies() []*http.Cookie {
// SetCookies 设置Cookies。有些功能必须登录之后才能使用,设置Cookies可以代替登录。
func (c *Client) SetCookies(cookies []*http.Cookie) {
c.cookies = cookies
var cookieStrings []string
cookieStrings := make([]string, 0, len(cookies))
for _, cookie := range c.cookies {
cookieStrings = append(cookieStrings, cookie.String())
}
Expand Down
2 changes: 1 addition & 1 deletion dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (c *Client) UploadDynamicBfs(fileName string, file io.Reader, category stri
ImageHeight int `json:"image_height"`
}
err = json.Unmarshal(ret, &data)
return data.ImageUrl, Size{Width: data.ImageWidth, Height: data.ImageHeight}, err
return data.ImageUrl, Size{Width: data.ImageWidth, Height: data.ImageHeight}, errors.WithStack(err)
}

// CreateDynamic 发表纯文本动态
Expand Down
14 changes: 7 additions & 7 deletions fav.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *Client) AddFavourFolder(title, intro string, privacy bool, cover string
}
var ret *FavourFolderInfo
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

// EditFavourFolder 修改收藏夹
Expand Down Expand Up @@ -76,7 +76,7 @@ func (c *Client) EditFavourFolder(mediaId int, title, intro string, privacy bool
}
var ret *FavourFolderInfo
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

// DeleteFavourFolder 删除收藏夹
Expand Down Expand Up @@ -251,7 +251,7 @@ func (c *Client) GetFavourFolderInfo(mediaId int) (*FavourFolderInfo, error) {
}
var ret *FavourFolderInfo
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

type AllFavourFolderInfo struct {
Expand Down Expand Up @@ -287,7 +287,7 @@ func (c *Client) GetAllFavourFolderInfo(upMid, attrType, rid int) (*AllFavourFol
}
var ret *AllFavourFolderInfo
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

type FavourInfo struct {
Expand Down Expand Up @@ -339,7 +339,7 @@ func (c *Client) GetFavourInfo(resources []Resource, platform string) ([]*Favour
}
var ret []*FavourInfo
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

type FavourList struct {
Expand Down Expand Up @@ -435,7 +435,7 @@ func (c *Client) GetFavourList(mediaId, tid int, keyword, order string, searchTy
}
var ret *FavourList
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

type FavourId struct {
Expand All @@ -462,5 +462,5 @@ func (c *Client) GetFavourIds(mediaId int, platform string) ([]*FavourId, error)
}
var ret []*FavourId
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}
2 changes: 1 addition & 1 deletion live.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type RoomInfo struct {
BgPic string `json:"bg_pic"`
UseOldArea bool `json:"use_old_area"`
} `json:"frame"`
//Badge interface{} `json:"badge"`
// Badge interface{} `json:"badge"`
MobileFrame struct {
Name string `json:"name"`
Value string `json:"value"`
Expand Down
3 changes: 2 additions & 1 deletion login.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ type QRCode struct {

// Encode a QRCode and return a raw PNG image.
func (result *QRCode) Encode() ([]byte, error) {
return qrcode.Encode(result.Url, qrcode.Medium, 256)
buf, err := qrcode.Encode(result.Url, qrcode.Medium, 256)
return buf, errors.WithStack(err)
}

// Print the QRCode in the console
Expand Down
8 changes: 4 additions & 4 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Client) GetUnreadMessage() (*UnreadMessage, error) {
}
var ret *UnreadMessage
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

type UnreadPrivateMessage struct {
Expand All @@ -51,7 +51,7 @@ func (c *Client) GetUnreadPrivateMessage() (*UnreadPrivateMessage, error) {
}
var ret *UnreadPrivateMessage
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

var deviceId string
Expand Down Expand Up @@ -229,7 +229,7 @@ func (c *Client) GetSessionMessages(talkerId, sessionType, size int, mobiApp str
}
var ret *SessionMessages
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}

type SessionList struct {
Expand Down Expand Up @@ -301,5 +301,5 @@ func (c *Client) GetSessions(sessionType int, mobiApp string) (*SessionList, err
}
var ret *SessionList
err = json.Unmarshal(data, &ret)
return ret, err
return ret, errors.WithStack(err)
}
8 changes: 5 additions & 3 deletions video.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type VideoInfo struct {
NoShare int `json:"no_share"`
ArcPay int `json:"arc_pay"`
FreeWatch int `json:"free_watch"`
}
} `json:"rights"`
Owner struct { // 视频UP主信息
Mid int `json:"mid"` // UP主mid
Name string `json:"name"` // UP主昵称
Expand Down Expand Up @@ -743,10 +743,11 @@ func (c *Client) FavourVideoByAvid(avid int, addMediaIds, delMediaIds []int) (bo
if len(biliJct) == 0 {
return false, errors.New("B站登录过期")
}
var addMediaIdStr, delMediaIdStr []string
addMediaIdStr := make([]string, 0, len(addMediaIds))
for _, id := range addMediaIds {
addMediaIdStr = append(addMediaIdStr, strconv.Itoa(id))
}
delMediaIdStr := make([]string, 0, len(delMediaIds))
for _, id := range delMediaIds {
delMediaIdStr = append(delMediaIdStr, strconv.Itoa(id))
}
Expand All @@ -773,10 +774,11 @@ func (c *Client) FavourVideoByBvid(bvid string, addMediaIds, delMediaIds []int)
if len(biliJct) == 0 {
return false, errors.New("B站登录过期")
}
var addMediaIdStr, delMediaIdStr []string
addMediaIdStr := make([]string, 0, len(addMediaIds))
for _, id := range addMediaIds {
addMediaIdStr = append(addMediaIdStr, strconv.Itoa(id))
}
delMediaIdStr := make([]string, 0, len(delMediaIds))
for _, id := range delMediaIds {
delMediaIdStr = append(delMediaIdStr, strconv.Itoa(id))
}
Expand Down

0 comments on commit 570bcb4

Please sign in to comment.