本文整理汇总了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))