Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
.gitignore | H A D | 19-May-2019 | 266 | |||
LICENSE | H A D | 19-May-2019 | 1.1 KiB | |||
README.md | H A D | 19-May-2019 | 957 | |||
client.go | H A D | 19-May-2019 | 2.4 KiB | |||
command.go | H A D | 19-May-2019 | 286 | |||
example_test.go | H A D | 19-May-2019 | 1.7 KiB | |||
idle.go | H A D | 19-May-2019 | 184 | |||
response.go | H A D | 19-May-2019 | 709 | |||
server.go | H A D | 19-May-2019 | 968 |
README.md
1# go-imap-idle 2 3[![GoDoc](https://godoc.org/github.com/emersion/go-imap-idle?status.svg)](https://godoc.org/github.com/emersion/go-imap-idle) 4 5[IDLE extension](https://tools.ietf.org/html/rfc2177) for [go-imap](https://github.com/emersion/go-imap). 6 7## Usage 8 9### Client 10 11```go 12// Let's assume c is an IMAP client 13var c *client.Client 14 15// Select a mailbox 16if _, err := c.Select("INBOX", false); err != nil { 17 log.Fatal(err) 18} 19 20idleClient := idle.NewClient(c) 21 22// Create a channel to receive mailbox updates 23updates := make(chan client.Update) 24c.Updates = updates 25 26// Start idling 27done := make(chan error, 1) 28go func() { 29 done <- idleClient.IdleWithFallback(nil, 0) 30}() 31 32// Listen for updates 33for { 34 select { 35 case update := <-updates: 36 log.Println("New update:", update) 37 case err := <-done: 38 if err != nil { 39 log.Fatal(err) 40 } 41 log.Println("Not idling anymore") 42 return 43 } 44} 45``` 46 47### Server 48 49```go 50s.Enable(idle.NewExtension()) 51``` 52 53## License 54 55MIT 56