Simulate a tcp connection in Go

后端 未结 4 1452
悲&欢浪女
悲&欢浪女 2020-12-29 15:46

In Go, a TCP connection (net.Conn) is a io.ReadWriteCloser. I\'d like to test my network code by simulating a TCP connection. There are two requirements that I have:

4条回答
  •  长情又很酷
    2020-12-29 15:59

    Most of the cases you do not need to mock net.Conn.

    You always can run a goroutine in your test code that will imitate the other side.

提交回复
热议问题