emersion / go-imap-idle

IDLE extension for go-imap
MIT License
34 stars 12 forks source link

Determine Update Type #10

Closed fipso closed 5 years ago

fipso commented 6 years ago

Hello, is there a way to know whether my update object is a MailBox, Expunge or Messages update ?

emersion commented 6 years ago

Use a type switch.

Akumzy commented 5 years ago

@emersion How? Please am really stuck here

emersion commented 5 years ago

https://gobyexample.com/switch

Akumzy commented 5 years ago

@emersion Am sorry am new to Golang I can't figure out what next to do here

switch t := update.(type) {
            case *client.MailboxUpdate:
                g := &client.MailboxUpdate{}
                m := g.Mailbox
                fmt.Println(m)
            //  log.Println("Mail box update")
            // case client.MessageUpdate:
            //  log.Println("Message update")
            // case client.ExpungeUpdate:
            //  log.Println("Expunge update")
            // case client.StatusUpdate:
            // log.Println(c.Mailbox().Recent)
            default:
                fmt.Printf("Don't know type %T\n", t)
            }