Latest returns the most recent event that has a non-empty payload, or (zero, false) if the ring is empty or no event has a payload yet. Used by /debug show with no argument.
()
| 197 | // (zero, false) if the ring is empty or no event has a payload yet. |
| 198 | // Used by /debug show with no argument. |
| 199 | func Latest() (Event, bool) { |
| 200 | mu.Lock() |
| 201 | defer mu.Unlock() |
| 202 | for i := len(events) - 1; i >= 0; i-- { |
| 203 | if events[i].Payload != "" { |
| 204 | return events[i], true |
| 205 | } |
| 206 | } |
| 207 | if len(events) == 0 { |
| 208 | return Event{}, false |
| 209 | } |
| 210 | return events[len(events)-1], true |
| 211 | } |
| 212 | |
| 213 | func truncatePayload(p string) string { |
| 214 | if len(p) <= maxPayloadBytes { |
no outgoing calls