Skip to content

Commit fd39e17

Browse files
committed
Drop temp var in loops
This was fixed in Go 1.22, see: https://go.dev/blog/loopvar-preview
1 parent a32e0d2 commit fd39e17

File tree

5 files changed

+0
-12
lines changed

5 files changed

+0
-12
lines changed

bot/processor.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ func (p *Processor) onMessage(b *gotgbot.Bot, ctx *ext.Context) error {
104104
text := msg.GetText()
105105

106106
for _, plg := range p.managerService.Plugins() {
107-
plg := plg
108107
for _, h := range plg.Handlers(&b.User) {
109-
h := h
110-
111108
handler, ok := h.(*plugin.CommandHandler)
112109
if !ok {
113110
continue
@@ -249,10 +246,7 @@ func (p *Processor) onCallback(b *gotgbot.Bot, ctx *ext.Context) error {
249246
}
250247

251248
for _, plg := range p.managerService.Plugins() {
252-
plg := plg
253249
for _, h := range plg.Handlers(&b.User) {
254-
h := h
255-
256250
handler, ok := h.(*plugin.CallbackHandler)
257251
if !ok {
258252
continue
@@ -371,9 +365,7 @@ func (p *Processor) onInlineQuery(b *gotgbot.Bot, ctx *ext.Context) error {
371365
}
372366

373367
for _, plg := range p.managerService.Plugins() {
374-
plg := plg
375368
for _, h := range plg.Handlers(&b.User) {
376-
h := h
377369
handler, ok := h.(*plugin.InlineHandler)
378370
if !ok {
379371
continue

plugin/expand/expand.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ func onExpand(b *gotgbot.Bot, c plugin.GobotContext) error {
134134
var sb strings.Builder
135135

136136
for _, url := range shortUrls {
137-
url := url
138137
if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
139138
url = fmt.Sprintf("http://%s", url)
140139
}

plugin/reminders/reminders.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func New(bot *gotgbot.Bot, service Service) *Plugin {
4646
}
4747

4848
for _, reminder := range reminders {
49-
reminder := reminder
5049
if time.Now().After(reminder.Time) {
5150
p.sendReminder(bot, reminder.ID)
5251
} else {

plugin/youtube/api.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func (d *DeArrowResponse) GetBestTitle() string {
121121
maxVotes := -1
122122
var title string
123123
for _, t := range d.Titles {
124-
t := t
125124
if t.Votes > maxVotes && !t.Original {
126125
maxVotes = t.Votes
127126
title = t.Title

utils/tgUtils/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func GetBestResolution(photo []gotgbot.PhotoSize) *gotgbot.PhotoSize {
7575
var filesize int64
7676
var bestResolution *gotgbot.PhotoSize
7777
for _, photoSize := range photo {
78-
photoSize := photoSize
7978
if photoSize.FileSize > filesize {
8079
filesize = photoSize.FileSize
8180
bestResolution = &photoSize

0 commit comments

Comments
 (0)