From 72dfbf4a0356f312d4bede463b8bf4d954b6f3aa Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 17 Jan 2025 20:39:18 -0500 Subject: [PATCH] spelling correct --- AniListFunctions.go | 8 ++++---- AniListUserFunctions.go | 7 ++++--- MALUserFunctions.go | 23 ++++++++++++----------- SimklUserFunctions.go | 7 ++++--- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/AniListFunctions.go b/AniListFunctions.go index d80930c..539f5d4 100644 --- a/AniListFunctions.go +++ b/AniListFunctions.go @@ -17,14 +17,14 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) { if login && (AniListJWT{}) != aniListJwt { response.Header.Add("Authorization", "Bearer "+aniListJwt.AccessToken) } else if login { - return nil, "Please login to anilist to make this request" + return nil, "Please login to AniList to make this request" } response.Header.Add("Content-Type", "application/json") response.Header.Add("Accept", "application/json") client := &http.Client{} - res, reserr := client.Do(response) - if reserr != nil { + res, resErr := client.Do(response) + if resErr != nil { log.Printf("Failed at res, %s\n", err) } @@ -148,7 +148,7 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime { return post } - if status == "404 Not Found" && login { + if status == "404 Not Found" { post = a.GetAniListItem(aniId, false) } diff --git a/AniListUserFunctions.go b/AniListUserFunctions.go index 7d247ff..e90d98d 100644 --- a/AniListUserFunctions.go +++ b/AniListUserFunctions.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "errors" "fmt" "io" "log" @@ -123,7 +124,7 @@ func (a *App) handleAniListCallback(wg *sync.WaitGroup) { go func() { defer wg.Done() - if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { log.Fatalf("listen: %s\n", err) } fmt.Println("Shutting down...") @@ -152,8 +153,8 @@ func getAniListAuthorizationToken(content string) AniListJWT { response.Header.Add("Accept", "application/json") client := &http.Client{} - res, reserr := client.Do(response) - if reserr != nil { + res, resErr := client.Do(response) + if resErr != nil { log.Printf("Failed at res, %s\n", err) } diff --git a/MALUserFunctions.go b/MALUserFunctions.go index 383e34f..24c837f 100644 --- a/MALUserFunctions.go +++ b/MALUserFunctions.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/base64" "encoding/json" + "errors" "fmt" "io" "log" @@ -79,10 +80,10 @@ func (a *App) CheckIfMyAnimeListLoggedIn() bool { if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 { return false } else { - var expresInConvertErr error + var expiresInConvertErr error myAnimeListJwt.TokenType = string(tokenType.Data) - myAnimeListJwt.ExpiresIn, expresInConvertErr = strconv.Atoi(string(expiresIn.Data)) - if expresInConvertErr != nil { + myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data)) + if expiresInConvertErr != nil { fmt.Println("unable to convert string to int") } myAnimeListJwt.AccessToken = string(accessToken.Data) @@ -111,10 +112,10 @@ func (a *App) MyAnimeListLogin() { a.handleMyAnimeListCallback(serverDone, verifier) serverDone.Wait() } else { - var expresInConvertErr error + var expiresInConvertErr error myAnimeListJwt.TokenType = string(tokenType.Data) - myAnimeListJwt.ExpiresIn, expresInConvertErr = strconv.Atoi(string(expiresIn.Data)) - if expresInConvertErr != nil { + myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data)) + if expiresInConvertErr != nil { fmt.Println("unable to convert string to int in Login function") } myAnimeListJwt.AccessToken = string(accessToken.Data) @@ -176,7 +177,7 @@ func (a *App) handleMyAnimeListCallback(wg *sync.WaitGroup, verifier *CodeVerifi go func() { defer wg.Done() - if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { log.Fatalf("listen: %s\n", err) } fmt.Println("Shutting down...") @@ -215,8 +216,8 @@ func getMyAnimeListAuthorizationToken(content string, verifier *CodeVerifier) My response.Header.Add("Content-Type", "application/x-www-form-urlencoded") client := &http.Client{} - res, reserr := client.Do(response) - if reserr != nil { + res, resErr := client.Do(response) + if resErr != nil { log.Printf("Failed at res, %s\n", err) } @@ -265,8 +266,8 @@ func refreshMyAnimeListAuthorizationToken() { response.Header.Add("Content-Type", "application/x-www-form-urlencoded") client := &http.Client{} - res, reserr := client.Do(response) - if reserr != nil { + res, resErr := client.Do(response) + if resErr != nil { log.Printf("Failed at res, %s\n", err) } diff --git a/SimklUserFunctions.go b/SimklUserFunctions.go index 45ecbfd..bd787db 100644 --- a/SimklUserFunctions.go +++ b/SimklUserFunctions.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "log" @@ -114,7 +115,7 @@ func (a *App) handleSimklCallback(wg *sync.WaitGroup) { go func() { defer wg.Done() - if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { log.Fatalf("listen: %s\n", err) } fmt.Println("Shutting down...") @@ -147,8 +148,8 @@ func getSimklAuthorizationToken(content string) SimklJWT { response.Header.Add("Content-Type", "application/json") client := &http.Client{} - res, reserr := client.Do(response) - if reserr != nil { + res, resErr := client.Do(response) + if resErr != nil { log.Printf("Failed at res, %s\n", err) }