summaryrefslogtreecommitdiff
path: root/danmaku/dmmsg
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-07-01 22:10:22 +0800
committerKeuin <[email protected]>2023-07-01 22:10:44 +0800
commitb8d0d0c3b6b2ffe40921aa4c247c101dd0ce958d (patch)
treec14f512312a6ee2fab6bdaef7cb55dfedbf19262 /danmaku/dmmsg
parent8f07f6f4d7e91a9e4b7164a39759907fac5fb8a1 (diff)
Refactor: rename consts to follow Go idiom. Fix const comment style.
Diffstat (limited to 'danmaku/dmmsg')
-rw-r--r--danmaku/dmmsg/danmu.go8
-rw-r--r--danmaku/dmmsg/util.go2
2 files changed, 5 insertions, 5 deletions
diff --git a/danmaku/dmmsg/danmu.go b/danmaku/dmmsg/danmu.go
index 2cc5dfa..f0229d2 100644
--- a/danmaku/dmmsg/danmu.go
+++ b/danmaku/dmmsg/danmu.go
@@ -23,11 +23,11 @@ func (dm DanMuMessage) String() string {
dm.SourceUser.Nickname, dm.SourceUser.UID, dm.Content)
}
-const kInvalidDanmakuJson = "invalid danmaku JSON document"
+const InvalidDanmakuJson = "invalid danmaku JSON document"
func ParseDanmakuMessage(body RawDanMuMessage) (dmm DanMuMessage, err error) {
if len(body.Info) != 16 {
- err = fmt.Errorf("%s: \"info\" length != 16", kInvalidDanmakuJson)
+ err = fmt.Errorf("%s: \"info\" length != 16", InvalidDanmakuJson)
return
}
@@ -41,14 +41,14 @@ func ParseDanmakuMessage(body RawDanMuMessage) (dmm DanMuMessage, err error) {
var ok bool
uid, ok := userInfo[0].(float64)
if !ok {
- err = fmt.Errorf("%s: uid is not a float64: %v", kInvalidDanmakuJson, userInfo[0])
+ err = fmt.Errorf("%s: uid is not a float64: %v", InvalidDanmakuJson, userInfo[0])
return
}
dmm.SourceUser.UID = int64(uid)
dmm.SourceUser.Nickname, ok = userInfo[1].(string)
if !ok {
- err = fmt.Errorf("%s: nickname is not a string: %v", kInvalidDanmakuJson, userInfo[1])
+ err = fmt.Errorf("%s: nickname is not a string: %v", InvalidDanmakuJson, userInfo[1])
return
}
return
diff --git a/danmaku/dmmsg/util.go b/danmaku/dmmsg/util.go
index 9d41ab9..d38814b 100644
--- a/danmaku/dmmsg/util.go
+++ b/danmaku/dmmsg/util.go
@@ -9,7 +9,7 @@ func castValue[T any](obj interface{}) (thing T, err error) {
casted, ok := (obj).(T)
if !ok {
err = fmt.Errorf("%s: required value is not of type \"%v\": %v",
- kInvalidDanmakuJson, reflect.TypeOf(thing).String(), obj)
+ InvalidDanmakuJson, reflect.TypeOf(thing).String(), obj)
return
}
thing = casted