refactor(backend): apply go fix updates for Go 1.26

This commit is contained in:
Yuan
2026-02-21 11:58:24 +08:00
parent add5db2522
commit c80879de98
9 changed files with 13 additions and 16 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/0x2E/fusion
go 1.25
go 1.26
require (
github.com/0x2E/feedfinder v0.1.1
+2 -2
View File
@@ -217,10 +217,10 @@ func (h *Handler) authMiddleware() gin.HandlerFunc {
}
}
func dataResponse(c *gin.Context, data interface{}) {
func dataResponse(c *gin.Context, data any) {
c.JSON(200, gin.H{"data": data})
}
func listResponse(c *gin.Context, data interface{}, total int) {
func listResponse(c *gin.Context, data any, total int) {
c.JSON(200, gin.H{"data": data, "total": total})
}
+1 -1
View File
@@ -17,7 +17,7 @@ func TestMarkItemsBatchValidation(t *testing.T) {
name string
path string
handler gin.HandlerFunc
body interface{}
body any
}{
{name: "read rejects too many ids", path: "/api/items/-/read", handler: (&Handler{}).markItemsRead, body: gin.H{"ids": ids}},
{name: "unread rejects empty ids", path: "/api/items/-/unread", handler: (&Handler{}).markItemsUnread, body: gin.H{"ids": []int64{}}},
@@ -16,7 +16,7 @@ func newTestRouter() *gin.Engine {
return gin.New()
}
func mustJSONBody(t *testing.T, payload interface{}) *bytes.Reader {
func mustJSONBody(t *testing.T, payload any) *bytes.Reader {
t.Helper()
body, err := json.Marshal(payload)
+1 -1
View File
@@ -156,7 +156,7 @@ func parseCacheControlMaxAgeSeconds(cacheControl string) int64 {
return 0
}
for _, part := range strings.Split(cacheControl, ",") {
for part := range strings.SplitSeq(cacheControl, ",") {
token := strings.TrimSpace(strings.ToLower(part))
if !strings.HasPrefix(token, "max-age=") {
continue
+1 -1
View File
@@ -14,7 +14,7 @@ func (s *Store) ListBookmarks(limit, offset int) ([]*model.Bookmark, error) {
FROM bookmarks
ORDER BY created_at DESC, id DESC
`
args := []interface{}{}
args := []any{}
if limit > 0 {
query += ` LIMIT :limit`
+1 -1
View File
@@ -198,7 +198,7 @@ type UpdateFeedParams struct {
// UpdateFeed performs partial update of feed fields using a single dynamic UPDATE query.
func (s *Store) UpdateFeed(id int64, params UpdateFeedParams) error {
setClauses := []string{}
args := []interface{}{sql.Named("id", id)}
args := []any{sql.Named("id", id)}
if params.GroupID != nil {
setClauses = append(setClauses, "group_id = :group_id")
+4 -7
View File
@@ -28,7 +28,7 @@ func (s *Store) ListItems(params ListItemsParams) ([]*model.Item, error) {
SELECT items.id, items.feed_id, items.guid, items.title, items.link, items.content, items.pub_date, items.unread, items.created_at
FROM items
`
args := []interface{}{}
args := []any{}
// Join feeds table if filtering by GroupID
if params.GroupID != nil {
@@ -208,10 +208,7 @@ func (s *Store) BatchUpdateItemsUnread(ids []int64, unread bool) error {
const chunkSize = 500
for start := 0; start < len(ids); start += chunkSize {
end := start + chunkSize
if end > len(ids) {
end = len(ids)
}
end := min(start+chunkSize, len(ids))
if err := s.batchUpdateItemsUnreadChunk(ids[start:end], unread); err != nil {
return err
@@ -227,7 +224,7 @@ func (s *Store) batchUpdateItemsUnreadChunk(ids []int64, unread bool) error {
}
placeholders := make([]string, len(ids))
args := make([]interface{}, 0, len(ids)+1)
args := make([]any, 0, len(ids)+1)
args = append(args, sql.Named("unread", boolToInt(unread)))
for i, id := range ids {
paramName := fmt.Sprintf("id%d", i)
@@ -341,7 +338,7 @@ func (s *Store) searchItemsLike(query string, limit int) ([]*SearchItemResult, e
// CountItems returns the total count of items matching the filter criteria.
func (s *Store) CountItems(params ListItemsParams) (int, error) {
query := `SELECT COUNT(*) FROM items`
args := []interface{}{}
args := []any{}
if params.GroupID != nil {
query += ` INNER JOIN feeds ON items.feed_id = feeds.id`
+1 -1
View File
@@ -345,7 +345,7 @@ func TestBatchUpdateItemsUnreadChunked(t *testing.T) {
feed := mustCreateFeed(t, store, group.ID, "Chunk Feed", "https://example.com/chunk-feed", "https://example.com", "")
inputs := make([]BatchCreateItemInput, 0, 520)
for i := 0; i < 520; i++ {
for i := range 520 {
inputs = append(inputs, BatchCreateItemInput{
GUID: fmt.Sprintf("chunk-guid-%d", i),
Title: "Chunk Item",