summaryrefslogtreecommitdiff
path: root/danmaku/dmpkg/decode.go
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/dmpkg/decode.go
parent8f07f6f4d7e91a9e4b7164a39759907fac5fb8a1 (diff)
Refactor: rename consts to follow Go idiom. Fix const comment style.
Diffstat (limited to 'danmaku/dmpkg/decode.go')
-rw-r--r--danmaku/dmpkg/decode.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/danmaku/dmpkg/decode.go b/danmaku/dmpkg/decode.go
index 7d9f796..e352fcc 100644
--- a/danmaku/dmpkg/decode.go
+++ b/danmaku/dmpkg/decode.go
@@ -7,14 +7,14 @@ import (
)
func DecodeExchange(data []byte) (exc DanmakuExchange, err error) {
- if ln := len(data); ln < kHeaderLength {
- err = fmt.Errorf("incomplete datagram: length = %v < %v", ln, kHeaderLength)
+ if ln := len(data); ln < HeaderLength {
+ err = fmt.Errorf("incomplete datagram: length = %v < %v", ln, HeaderLength)
return
}
// unpack header
var exchangeHeader DanmakuExchangeHeader
- err = struc.Unpack(bytes.NewReader(data[:kHeaderLength]), &exchangeHeader)
+ err = struc.Unpack(bytes.NewReader(data[:HeaderLength]), &exchangeHeader)
if err != nil {
err = fmt.Errorf("cannot unpack exchange header: %w", err)
return
@@ -22,9 +22,9 @@ func DecodeExchange(data []byte) (exc DanmakuExchange, err error) {
headerLength := exchangeHeader.HeaderLength
// validate header length, fail fast if not match
- if headerLength != kHeaderLength {
+ if headerLength != HeaderLength {
err = fmt.Errorf("invalid header length, "+
- "the protocol implementation might be obsolete: %v != %v", headerLength, kHeaderLength)
+ "the protocol implementation might be obsolete: %v != %v", headerLength, HeaderLength)
return
}