refactor: use strconv instead of fmt.Sscanf
This commit is contained in:
@@ -2,6 +2,7 @@ package jikan
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -236,8 +237,7 @@ func (a Anime) DurationSeconds() float64 {
|
|||||||
if c >= '0' && c <= '9' {
|
if c >= '0' && c <= '9' {
|
||||||
currentNum += string(c)
|
currentNum += string(c)
|
||||||
} else if c == ' ' && currentNum != "" {
|
} else if c == ' ' && currentNum != "" {
|
||||||
val := 0
|
val, _ := strconv.Atoi(currentNum)
|
||||||
fmt.Sscanf(currentNum, "%d", &val)
|
|
||||||
if isHours {
|
if isHours {
|
||||||
hours = val
|
hours = val
|
||||||
} else {
|
} else {
|
||||||
@@ -246,15 +246,13 @@ func (a Anime) DurationSeconds() float64 {
|
|||||||
currentNum = ""
|
currentNum = ""
|
||||||
} else if len(currentNum) > 0 && (c == 'h' || c == 'H') {
|
} else if len(currentNum) > 0 && (c == 'h' || c == 'H') {
|
||||||
isHours = true
|
isHours = true
|
||||||
val := 0
|
val, _ := strconv.Atoi(currentNum)
|
||||||
fmt.Sscanf(currentNum, "%d", &val)
|
|
||||||
hours = val
|
hours = val
|
||||||
currentNum = ""
|
currentNum = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if currentNum != "" {
|
if currentNum != "" {
|
||||||
val := 0
|
val, _ := strconv.Atoi(currentNum)
|
||||||
fmt.Sscanf(currentNum, "%d", &val)
|
|
||||||
if isHours {
|
if isHours {
|
||||||
hours = val
|
hours = val
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user