From 49082656b79cea1d5ea21fe92564eaddd9b5843a Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 14 Jul 2023 22:29:35 +0800 Subject: Refactor: use proper const name. --- bilibili/client.go | 6 +++--- logging/logger.go | 20 ++++++++++---------- recording/watcher.go | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bilibili/client.go b/bilibili/client.go index 17a42d6..4abad60 100644 --- a/bilibili/client.go +++ b/bilibili/client.go @@ -13,8 +13,8 @@ import ( ) const ( - // kUserAgent: the default user-agent header to use when communicating with bilibili. - kUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + + // userAgent: the default user-agent header to use when communicating with bilibili. + userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" ) @@ -41,7 +41,7 @@ func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, log return &Bilibili{ logger: logger, - userAgent: kUserAgent, + userAgent: userAgent, http: http.DefaultClient, ctx: ctx, netTypes: nets, diff --git a/logging/logger.go b/logging/logger.go index 9724c2f..f5de019 100644 --- a/logging/logger.go +++ b/logging/logger.go @@ -21,21 +21,21 @@ type Logger struct { } const ( - kDebug = "DEBUG" - kInfo = "INFO" - kWarning = "WARNING" - kError = "ERROR" - kFatal = "FATAL" + levelDebug = "DEBUG" + levelInfo = "INFO" + levelWarning = "WARNING" + levelError = "ERROR" + levelFatal = "FATAL" ) func NewWrappedLogger(delegate *log.Logger, name string) Logger { return Logger{ delegate: delegate, - debugHeader: fmt.Sprintf("[%v][%v]", name, kDebug), - infoHeader: fmt.Sprintf("[%v][%v]", name, kInfo), - warningHeader: fmt.Sprintf("[%v][%v]", name, kWarning), - errorHeader: fmt.Sprintf("[%v][%v]", name, kError), - fatalHeader: fmt.Sprintf("[%v][%v]", name, kFatal), + debugHeader: fmt.Sprintf("[%v][%v]", name, levelDebug), + infoHeader: fmt.Sprintf("[%v][%v]", name, levelInfo), + warningHeader: fmt.Sprintf("[%v][%v]", name, levelWarning), + errorHeader: fmt.Sprintf("[%v][%v]", name, levelError), + fatalHeader: fmt.Sprintf("[%v][%v]", name, levelFatal), } } diff --git a/recording/watcher.go b/recording/watcher.go index 181e0fc..0e4b459 100644 --- a/recording/watcher.go +++ b/recording/watcher.go @@ -24,7 +24,7 @@ type liveInfo struct { } const ( - kHeartBeatInterval = 30 * time.Second + heartBeatInterval = 30 * time.Second ) // watch monitors live room status by subscribing messages from Bilibili danmaku server, @@ -80,7 +80,7 @@ func watch( } // create heartbeat timer - heartBeatTimer := time.NewTicker(kHeartBeatInterval) + heartBeatTimer := time.NewTicker(heartBeatInterval) defer func() { heartBeatTimer.Stop() }() logger.Info("Checking initial live status...") -- cgit v1.2.3