本文整理匯總了Golang中net/textproto.Conn.ReadDotBytes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.ReadDotBytes方法的具體用法?Golang Conn.ReadDotBytes怎麽用?Golang Conn.ReadDotBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/textproto.Conn
的用法示例。
在下文中一共展示了Conn.ReadDotBytes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: converse
func converse(c *textproto.Conn, verifyOnly bool) {
write(c, "220 At your service")
var msg Msg
for {
s, err := read(c)
if err == io.EOF {
return
}
if verifyOnly {
log.Println("Incoming:", s)
}
cmd := strings.ToUpper(s[:4])
switch cmd {
case "EHLO":
write(c, "250-8BITMIME")
fallthrough
case "HELO":
write(c, "250 I need orders")
case "MAIL":
msg.From = addrRegex.FindStringSubmatch(s)[1]
write(c, "250 In your name")
case "RCPT":
addr := addrRegex.FindStringSubmatch(s)[1]
msg.To = append(msg.To, addr)
write(c, "250 Defending your honour")
case "DATA":
if verifyOnly {
write(c, "502 Verification service only")
return
}
write(c, "354 Give me a quest!")
data, err := c.ReadDotBytes()
if err != nil {
panic(err)
}
msg.Data = data
defaultHandle(&msg)
write(c, "250 We move")
case "RSET":
write(c, "250 OK")
case "QUIT":
write(c, "221 For the king")
default:
log.Println("Unknown command:", s)
}
}
}