Optimize: bump to Go 1.21 and clean some code

This commit is contained in:
VnPower
2023-08-14 19:41:26 +07:00
parent e9e8c0801b
commit 0a76dc83dd
6 changed files with 5 additions and 13 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
module pixivfe
go 1.20
go 1.21
require (
github.com/goccy/go-json v0.10.2
+1 -1
View File
@@ -81,7 +81,7 @@ func (p *PixivClient) GetArtworkByID(id string) (*models.Illust, error) {
sort.Sort(sort.Reverse(sort.IntSlice(ids)))
idsString := ""
count := Min(len(ids), 30)
count := min(len(ids), 30)
for i := 0; i < count; i++ {
idsString += fmt.Sprintf("&ids[]=%d", ids[i])
-8
View File
@@ -1,8 +0,0 @@
package handler
func Min(x, y int) int {
if x < y {
return x
}
return y
}
+1 -1
View File
@@ -98,7 +98,7 @@ func (p *PixivClient) GetDiscoveryArtwork(mode string, count int) ([]models.Illu
var artworks []models.IllustShort
for count > 0 {
itemsForRequest := Min(100, count)
itemsForRequest := min(100, count)
count -= itemsForRequest
+1 -1
View File
@@ -85,7 +85,7 @@ func (p *PixivClient) GetLandingPage(mode string) (models.LandingArtworks, error
for i := 0; i < len(pages.RecommendedByTags); i++ {
temp := pages.RecommendedByTags[i]
temp.Artworks = artworks.Artworks[count : count+Min(len(temp.Ids), 18)]
temp.Artworks = artworks.Artworks[count : count+min(len(temp.Ids), 18)]
context.RecommendByTags = append(context.RecommendByTags, temp.LandingRecommendByTags)
count += len(temp.Ids)
+1 -1
View File
@@ -67,7 +67,7 @@ func (p *PixivClient) GetUserArtworksID(id string, category string, page int) (s
}
start := (page - 1) * int(worksPerPage)
end := int(math.Min(float64(page)*worksPerPage, worksNumber)) // no overflow
end := int(min(float64(page)*worksPerPage, worksNumber)) // no overflow
for _, k := range ids[start:end] {
idsString += fmt.Sprintf("&ids[]=%d", k)