From efb8aba1a699239949bbc7110577c59a5287fbfe Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Tue, 23 Sep 2025 00:17:16 +0200 Subject: [PATCH 1/3] chore: log TibiaDataStringToInteger error on debug --- src/TibiaDataUtils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TibiaDataUtils.go b/src/TibiaDataUtils.go index e3b6670..98ac64d 100644 --- a/src/TibiaDataUtils.go +++ b/src/TibiaDataUtils.go @@ -129,7 +129,10 @@ func TibiaDataStringToInteger(data string) int { returnData, err := strconv.Atoi(str) if err != nil { - log.Printf("[warning] TibiaDataStringToInteger: couldn't convert string into int. error: %s", err) + if TibiaDataDebug { + log.Printf("[warning] TibiaDataStringToInteger: failed to parse '%s' as integer - returning 0", data) + } + return 0 } return returnData From d345564d270bfec05f68e90a9d00749849d16d3b Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Tue, 23 Sep 2025 00:18:09 +0200 Subject: [PATCH 2/3] chore: use switches instead --- src/TibiaCharactersCharacter.go | 5 +++-- src/TibiaGuildsOverview.go | 10 ++++++---- src/TibiaSpellsSpell.go | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index b573486..1034637 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -279,9 +279,10 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string, url string) (CharacterR AccountInformationData.Created = TibiaDataDatetime(RowData) case "Position:": TmpPosition := strings.Split(RowData, "<") - if SectionName == "Character Information" { + switch SectionName { + case "Character Information": CharacterInfoData.Position = strings.TrimSpace(TmpPosition[0]) - } else if SectionName == "Account Information" { + case "Account Information": AccountInformationData.Position = strings.TrimSpace(TmpPosition[0]) } diff --git a/src/TibiaGuildsOverview.go b/src/TibiaGuildsOverview.go index 36f365a..88c3d80 100644 --- a/src/TibiaGuildsOverview.go +++ b/src/TibiaGuildsOverview.go @@ -46,9 +46,10 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string, url string) (G // Figure out the guild category s.Find(".Text").Each(func(index int, s *goquery.Selection) { tableName := s.Nodes[0].FirstChild.Data - if strings.Contains(tableName, "Active Guilds") { + switch { + case strings.Contains(tableName, "Active Guilds"): GuildCategory = "active" - } else if strings.Contains(tableName, "Guilds in Course of Formation") { + case strings.Contains(tableName, "Guilds in Course of Formation"): GuildCategory = "formation" } }) @@ -75,9 +76,10 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string, url string) (G } // Adding OneGuild to correct category - if GuildCategory == "active" { + switch GuildCategory { + case "active": ActiveGuilds = append(ActiveGuilds, OneGuild) - } else if GuildCategory == "formation" { + case "formation": FormationGuilds = append(FormationGuilds, OneGuild) } }) diff --git a/src/TibiaSpellsSpell.go b/src/TibiaSpellsSpell.go index c3cbd0a..6366175 100644 --- a/src/TibiaSpellsSpell.go +++ b/src/TibiaSpellsSpell.go @@ -106,10 +106,11 @@ func TibiaSpellsSpellImpl(spell string, BoxContentHTML string, url string) (Spel SectionName := s.Find(".CaptionInnerContainer div.Text").Text() // Determine if this is the spell or rune section - if SectionName == "Spell Information" { + switch SectionName { + case "Spell Information": SpellInformationSection = "spell" SpellsHasSpellSection = true - } else if SectionName == "Rune Information" { + case "Rune Information": SpellInformationSection = "rune" SpellsHasRuneSection = true } From f169c8f5d0fc2d709147869e9e841b2ca5e2f204 Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Tue, 23 Sep 2025 12:33:50 +0200 Subject: [PATCH 3/3] docs: lowercase Codecov url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d26b149..0ee230f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # TibiaData API in Golang [![GitHub CI](https://img.shields.io/github/actions/workflow/status/tibiadata/tibiadata-api-go/build.yml?branch=main&logo=github)](https://github.com/tibiadata/tibiadata-api-go/actions/workflows/build.yml) -[![Codecov](https://codecov.io/gh/TibiaData/tibiadata-api-go/branch/main/graph/badge.svg?token=PSBNLBI10C)](https://codecov.io/gh/TibiaData/tibiadata-api-go) +[![Codecov](https://codecov.io/gh/tibiadata/tibiadata-api-go/branch/main/graph/badge.svg?token=PSBNLBI10C)](https://codecov.io/gh/tibiadata/tibiadata-api-go) [![GitHub go.mod version](https://img.shields.io/github/go-mod/go-version/tibiadata/tibiadata-api-go?logo=go)](https://github.com/tibiadata/tibiadata-api-go/blob/main/go.mod) [![GitHub release](https://img.shields.io/github/v/release/tibiadata/tibiadata-api-go?sort=semver&logo=github)](https://github.com/tibiadata/tibiadata-api-go/releases) [![Docker image size (tag)](https://img.shields.io/docker/image-size/tibiadata/tibiadata-api-go/latest?logo=docker)](https://hub.docker.com/r/tibiadata/tibiadata-api-go)