Documentation ¶
Index ¶
- Constants
- Variables
- type Expect
- func (exp *Expect) Buffer() []byte
- func (exp *Expect) Close() error
- func (exp *Expect) Expect(expr string) (m Match, err error)
- func (exp *Expect) ExpectEOF() error
- func (exp *Expect) ExpectRegexp(pat *regexp.Regexp) (Match, error)
- func (exp *Expect) Send(s string) error
- func (exp *Expect) SendLn(lines ...string) error
- func (exp *Expect) SendMasked(s string) error
- func (exp *Expect) SetLogger(logger Logger)
- func (exp *Expect) SetTimeout(d time.Duration)
- func (exp *Expect) Timeout() time.Duration
- type Logger
- type Match
- type NilLogger
- func (*NilLogger) Close(time.Time)
- func (*NilLogger) EOF(time.Time)
- func (*NilLogger) ExpectCall(time.Time, *regexp.Regexp)
- func (*NilLogger) ExpectReturn(time.Time, Match, error)
- func (*NilLogger) Recv(time.Time, []byte)
- func (*NilLogger) Send(time.Time, []byte)
- func (*NilLogger) SendMasked(time.Time, []byte)
Constants ¶
const READ_SIZE = 4094
READ_SIZE is the largest amount of data expect attempts to read in a single I/O operation. This likely needs some research and tuning.
Variables ¶
var ErrTimeout = errors.New("Expect Timeout")
ErrTimeout is returned from exp.Expect*() when a timeout is reached.
Functions ¶
This section is empty.
Types ¶
type Expect ¶
type Expect struct {
// contains filtered or unexported fields
}
Expect is a program interaction session.
func Create ¶
func Create(pty io.ReadWriteCloser, killer func()) (exp *Expect)
Create an Expect instance from something that we can do read/writes off of.
Note: Close() must be called to cleanup this process.
func Spawn ¶
Create an Expect instance from a command. Effectively the same as Create(pty.Start(exec.Command(name, args...)))
func (*Expect) Buffer ¶
Return the current buffer.
Note: This is not all data received off the network, but data that has been received for processing.
func (*Expect) ExpectRegexp ¶
ExpectRegexp searches the I/O read stream for a pattern within .Timeout()
func (*Expect) SendMasked ¶
Send data, but mark it as masked to observers. Use this for passwords
func (*Expect) SetTimeout ¶
SetTimeout(Duration) sets the amount of time an Expect() call will wait for the output to appear.
type Logger ¶
type Logger interface { // API user sent an item Send(time.Time, []byte) // API user sent a masked item. The masked data is included, but the API user is advised to // not log this data in production. SendMasked(time.Time, []byte) // Data is received by the same goroutine as the API user. Recv(time.Time, []byte) // Data is received off the network RecvNet(time.Time, []byte) // EOF has been reached. Time is when the EOF was received off the network RecvEOF(time.Time) // API user ran some form of Expect* call ExpectCall(time.Time, *regexp.Regexp) // API user got a return back from an Expect* call ExpectReturn(time.Time, Match, error) // Close the log file / this is the last item Close(time.Time) }
func StderrLogger ¶
func StderrLogger() Logger