From a07ef4346162a50aca9fbbff35d3558a831d6d3b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 31 Jan 2019 11:35:43 +1100 Subject: [PATCH] Add badges, fix spello, and test unresolvable dials (#68) Add badges, fix spello, and test unresolvable dials --- README.md | 6 +++++- interface.go | 2 +- old_go_warning.go | 6 ------ reuse_test.go | 10 ++++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) delete mode 100644 old_go_warning.go diff --git a/README.md b/README.md index 1db5ae5..4a4605b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # go-reuseport -[![travisbadge](https://travis-ci.org/libp2p/go-reuseport.svg)](https://travis-ci.org/libp2p/go-reuseport) +[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai) +[![](https://img.shields.io/badge/project-libp2p-blue.svg?style=flat-square)](https://libp2p.io/) +[![](https://img.shields.io/badge/freenode-%23libp2p-blue.svg?style=flat-square)](https://webchat.freenode.net/?channels=%23libp2p) +[![codecov](https://codecov.io/gh/libp2p/go-reuseport/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-reuseport) +[![Travis CI](https://travis-ci.org/libp2p/go-reuseport.svg?branch=master)](https://travis-ci.org/libp2p/go-reuseport) **NOTE:** This package REQUIRES go >= 1.11. diff --git a/interface.go b/interface.go index 381710a..64b48af 100644 --- a/interface.go +++ b/interface.go @@ -49,7 +49,7 @@ func ListenPacket(network, address string) (net.PacketConn, error) { } // Dial dials the given network and address. see net.Dialer.Dial -// Returns a net.Conn created from a file discriptor for a socket +// Returns a net.Conn created from a file descriptor for a socket // with SO_REUSEPORT and SO_REUSEADDR option set. func Dial(network, laddr, raddr string) (net.Conn, error) { nla, err := ResolveAddr(network, laddr) diff --git a/old_go_warning.go b/old_go_warning.go deleted file mode 100644 index 835d53c..0000000 --- a/old_go_warning.go +++ /dev/null @@ -1,6 +0,0 @@ -// +build !go1.11 - -"go-reuseport requires go >= 1.11" - -; - diff --git a/reuse_test.go b/reuse_test.go index a7ca69d..883f89e 100644 --- a/reuse_test.go +++ b/reuse_test.go @@ -6,6 +6,9 @@ import ( "strings" "testing" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) @@ -43,3 +46,10 @@ func TestListenPacketWildcardAddress(t *testing.T) { require.NoError(t, err) pc.Close() } + +func TestErrorWhenDialUnresolvable(t *testing.T) { + _, err := Dial("asd", "127.0.0.1:1234", "127.0.0.1:1234") + assert.IsType(t, net.UnknownNetworkError(""), errors.Cause(err)) + _, err = Dial("tcp", "a.b.c.d:1234", "a.b.c.d:1235") + assert.Error(t, err) +}