You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to return FetchItemDataBodySection inside a Goroutines. I already checked if body_section.Literal is nil but I'm still getting the same error.
literal := body_section.Literal
if literal == nil {
return
}
Here is my code below
all_seq_nums := result.AllSeqNums()
count := len(all_seq_nums)
if count > 0 {
thread, _ := strconv.Atoi(thread)
semaphore := make(chan struct{}, thread)
var wg sync.WaitGroup
for seq_num := uint32(0); seq_num < uint32(count) ; seq_num++ {
wg.Add(1)
semaphore <- struct{}{}
go func(seq_num uint32) {
defer wg.Done()
defer func() { <-semaphore }()
seq_set := imap.SeqSetNum(all_seq_nums[seq_num])
fetch_options := &imap.FetchOptions{
BodySection: []*imap.FetchItemBodySection{{}},
}
fetch_cmd := client.Fetch(seq_set, fetch_options)
if fetch_cmd == nil {
return
}
msg := fetch_cmd.Next()
if msg == nil {
fmt.Print("\n[-] Message not found, skipping...")
return
}
var body_section imapclient.FetchItemDataBodySection
ok := false
for {
item := msg.Next()
if item == nil {
break
}
body_section, ok = item.(imapclient.FetchItemDataBodySection)
if ok {
break
}
}
if ok {
literal := body_section.Literal
if literal == nil {
return
}
mr, err := mail.CreateReader(literal)
if err == nil {
for {
p, err := mr.NextPart()
if err == io.EOF {
break
}
switch p.Header.(type) {
case *mail.InlineHeader:
b, _ := io.ReadAll(p.Body)
parse_message(string(b), imap_credential, mailbox_folder, all_seq_nums[seq_num])
}
}
}
}
fetch_cmd.Close()
}(seq_num)
}
wg.Wait()
}
The text was updated successfully, but these errors were encountered:
Hi Salut, I'm facing this issue.
Here is my error below.
I'm trying to return FetchItemDataBodySection inside a Goroutines. I already checked if body_section.Literal is nil but I'm still getting the same error.
Here is my code below
The text was updated successfully, but these errors were encountered: