1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Use modern for loops

Go 1.22 introduced a new [for-range](https://go.dev/ref/spec#For_range)
construct that looks a tad better than the usual `for i := 0; i < N; i++`
construct. I also tool the liberty of replacing some
`for i := 0; i < len(myitemsarray); i++ { … myitemsarray[i] …}`
with  `for item := range myitemsarray` when `myitemsarray` contains only pointers.
This commit is contained in:
jvoisin 2024-02-29 01:01:20 +01:00 committed by Frédéric Guillot
parent f4f8342245
commit 645a817685
7 changed files with 23 additions and 23 deletions

View file

@ -150,10 +150,10 @@ func (s *Storage) createEntry(tx *sql.Tx, entry *model.Entry) error {
return fmt.Errorf(`store: unable to create entry %q (feed #%d): %v`, entry.URL, entry.FeedID, err)
}
for i := 0; i < len(entry.Enclosures); i++ {
entry.Enclosures[i].EntryID = entry.ID
entry.Enclosures[i].UserID = entry.UserID
err := s.createEnclosure(tx, entry.Enclosures[i])
for _, enclosure := range entry.Enclosures {
enclosure.EntryID = entry.ID
enclosure.UserID = entry.UserID
err := s.createEnclosure(tx, enclosure)
if err != nil {
return err
}