From 50629f2e4e205fe3cc8bd0edf7e8aa0ae2602fb2 Mon Sep 17 00:00:00 2001 From: Qeynos Date: Mon, 16 Sep 2024 18:32:48 +0800 Subject: [PATCH] Modify the if-else statements to switch statements in accordance with the linter --- internal/reader/processor/processor.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/reader/processor/processor.go b/internal/reader/processor/processor.go index 207e123a752..1395ebb0865 100644 --- a/internal/reader/processor/processor.go +++ b/internal/reader/processor/processor.go @@ -582,12 +582,13 @@ func fetchBilibiliWatchTime(websiteURL string) (int, error) { bilibiliVideoId := bilibiliVideoIdRegex.FindStringSubmatch(websiteURL) var bilibiliApiURL string - if bilibiliVideoId[1] != "" { + switch { + case bilibiliVideoId[1] != "": bilibiliApiURL = "https://api.bilibili.com/x/web-interface/view?aid=" + bilibiliVideoId[1] - } else if bilibiliVideoId[2] != "" { + case bilibiliVideoId[2] != "": bilibiliApiURL = "https://api.bilibili.com/x/web-interface/view?bvid=" + bilibiliVideoId[2] - } else { - return 0, errors.New("video id has not found") + default: + return 0, fmt.Errorf("video id has not found") } responseHandler := fetcher.NewResponseHandler(requestBuilder.ExecuteRequest(bilibiliApiURL))