Skip to content

Commit

Permalink
fix: Use list append instead of indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
joeirimpan committed Jun 27, 2022
1 parent a1df02b commit 175770d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/messenger/postback/postback.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ func (p *Postback) Push(m messenger.Message) error {
}

if len(m.Attachments) > 0 {
a := make([]attachment, 0, len(m.Attachments))
for i := 0; i < len(m.Attachments); i++ {
a[i] = attachment{
Name: m.Attachments[i].Name,
Header: m.Attachments[i].Header,
Content: make([]byte, len(m.Attachments[i].Content)),
files := make([]attachment, 0, len(m.Attachments))
for _, f := range m.Attachments {
a := attachment{
Name: f.Name,
Header: f.Header,
Content: make([]byte, len(f.Content)),
}
copy(a[i].Content, m.Attachments[i].Content)
copy(a.Content, f.Content)
files = append(files, a)
}
}

Expand Down

0 comments on commit 175770d

Please sign in to comment.