本文整理匯總了Golang中net/textproto.Conn.ReadResponse方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.ReadResponse方法的具體用法?Golang Conn.ReadResponse怎麽用?Golang Conn.ReadResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/textproto.Conn
的用法示例。
在下文中一共展示了Conn.ReadResponse方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: cmd
func cmd(c *textproto.Conn, expectedCode int, format string, args ...interface{}) error {
id, err := c.Cmd(format, args...)
if err != nil {
return err
}
c.StartResponse(id)
_, _, err = c.ReadResponse(expectedCode)
c.EndResponse(id)
return err
}
示例2: playScriptAgainst
// playScriptAgainst an existing connection, does not handle server greeting
func playScriptAgainst(t *testing.T, c *textproto.Conn, script []scriptStep) error {
for i, step := range script {
id, err := c.Cmd(step.send)
if err != nil {
return fmt.Errorf("Step %d, failed to send %q: %v", i, step.send, err)
}
c.StartResponse(id)
code, msg, err := c.ReadResponse(step.expect)
if err != nil {
err = fmt.Errorf("Step %d, sent %q, expected %v, got %v: %q",
i, step.send, step.expect, code, msg)
}
c.EndResponse(id)
if err != nil {
// Return after c.EndResponse so we don't hang the connection
return err
}
}
return nil
}
示例3:
}
for _, tv := range variants {
variant := tv
Describe(variant.name, func() {
cmd := func(format string, args ...interface{}) {
_, err := c.Cmd(format, args...)
Expect(err).NotTo(HaveOccurred())
}
getres := func(format string, args ...interface{}) func(int) (string, error) {
return func(code int) (string, error) {
cmd(format, args...)
_, lineRes, err := c.ReadResponse(code)
Expect(err).NotTo(HaveOccurred())
return lineRes, err
}
}
res := func(format string, args ...interface{}) func(int, string) {
return func(code int, line string) {
lineRes, err := getres(format, args...)(code)
if err != nil {
return
}
Expect(lineRes).To(Equal(line))