You can hook into the lifecycle of Expect and Send operations using observers.
ExpectObserver
Called after each Expect operation.
matchers: The list of active matchers when an error occurred, or the matchers that matched buf if err is nil.buf: The captured output that was matched against.err: The error that occurred (can be nil).
type ExpectObserver func(matchers []Matcher, buf string, err error)
SendObserver
Called after each Send operation.
msg: The string that was sent.num: The number of bytes actually sent.err: The error that occurred (can be nil).
type SendObserver func(msg string, num int, err error)