You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
874 B

  1. //go:build !go1.10
  2. // +build !go1.10
  3. package conn
  4. import (
  5. "net"
  6. "time"
  7. )
  8. // Only Go1.10 has a proper net.Conn implementation that
  9. // has the SetDeadline method implemented as per
  10. // https://github.com/golang/go/commit/e2dd8ca946be884bb877e074a21727f1a685a706
  11. // lest we run into problems like
  12. // https://github.com/tendermint/tendermint/issues/851
  13. // so for go versions < Go1.10 use our custom net.Conn creator
  14. // that doesn't return an `Unimplemented error` for net.Conn.
  15. // Before https://github.com/tendermint/tendermint/commit/49faa79bdce5663894b3febbf4955fb1d172df04
  16. // we hadn't cared about errors from SetDeadline so swallow them up anyways.
  17. type pipe struct {
  18. net.Conn
  19. }
  20. func (p *pipe) SetDeadline(t time.Time) error {
  21. return nil
  22. }
  23. func NetPipe() (net.Conn, net.Conn) {
  24. p1, p2 := net.Pipe()
  25. return &pipe{p1}, &pipe{p2}
  26. }
  27. var _ net.Conn = (*pipe)(nil)