github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/internal/fakesmtp/connection.go (about) 1 package fakesmtp 2 3 import ( 4 "bufio" 5 "fmt" 6 "net" 7 ) 8 9 //Connection of a client with our server 10 type Connection struct { 11 conn net.Conn 12 address string 13 time int64 14 bufin *bufio.Reader 15 bufout *bufio.Writer 16 } 17 18 //write something to the client on the connection 19 func (c *Connection) write(s string) { 20 c.bufout.WriteString(s + "\r\n") 21 c.bufout.Flush() 22 } 23 24 //read a string from the connected client 25 func (c *Connection) read() string { 26 reply, err := c.bufin.ReadString('\n') 27 28 if err != nil { 29 fmt.Println("e ", err) 30 } 31 return reply 32 }