From b8d0d0c3b6b2ffe40921aa4c247c101dd0ce958d Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 1 Jul 2023 22:10:22 +0800 Subject: Refactor: rename consts to follow Go idiom. Fix const comment style. --- danmaku/dmpkg/decode.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'danmaku/dmpkg/decode.go') 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 } -- cgit v1.2.3