Skip to content

Commit

Permalink
fix:变量名 lock -> globalLock
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy0411 committed Dec 14, 2024
1 parent f83540c commit 739fa17
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions niu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

var (
db = &model{}
lock sync.Mutex
globalLock sync.Mutex
ErrNoBoys = errors.New("暂时没有男孩子哦")

Check failure on line 19 in niu/main.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported var ErrNoBoys should have comment or be unexported (revive)
ErrNoGirls = errors.New("暂时没有女孩子哦")
ErrNoNiuNiu = errors.New("你还没有牛牛呢,快去注册吧!")
Expand Down Expand Up @@ -46,8 +46,8 @@ func init() {

// SetWordNiuNiu length > 0 就增加 , length < 0 就减小
func SetWordNiuNiu(gid, uid int64, length float64) error {
lock.Lock()
defer lock.Unlock()
globalLock.Lock()
defer globalLock.Unlock()
niu, err := db.getWordNiuNiu(gid, uid)
if err != nil {
return err
Expand All @@ -57,16 +57,16 @@ func SetWordNiuNiu(gid, uid int64, length float64) error {
}

func GetWordNiuNiu(gid, uid int64) (float64, error) {

Check failure on line 59 in niu/main.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function GetWordNiuNiu should have comment or be unexported (revive)
lock.Lock()
defer lock.Unlock()
globalLock.Lock()
defer globalLock.Unlock()

niu, err := db.getWordNiuNiu(gid, uid)
return niu.Length, err
}

func GetRankingInfo(gid int64, t bool) (BaseInfos, error) {

Check failure on line 67 in niu/main.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function GetRankingInfo should have comment or be unexported (revive)
lock.Lock()
defer lock.Unlock()
globalLock.Lock()
defer globalLock.Unlock()
var (
list users
err error
Expand All @@ -91,8 +91,8 @@ func GetRankingInfo(gid int64, t bool) (BaseInfos, error) {

// GetGroupUserRank 获取指定用户在群中的排名
func GetGroupUserRank(gid, uid int64) (int, error) {
lock.Lock()
defer lock.Unlock()
globalLock.Lock()
defer globalLock.Unlock()
niu, err := db.getWordNiuNiu(gid, uid)
if err != nil {
return -1, err
Expand Down

0 comments on commit 739fa17

Please sign in to comment.