diff --git a/ifaces.go b/ifaces.go new file mode 100644 index 0000000..42f4ddd --- /dev/null +++ b/ifaces.go @@ -0,0 +1,8 @@ +package common + +import "net" + +// Dialer is an interface that should exist in stdlib honestly. Make it make sense that it doesn't. +type Dialer interface { + Dial(network, address string) (net.Conn, error) +} diff --git a/ifaces_test.go b/ifaces_test.go new file mode 100644 index 0000000..a3268f6 --- /dev/null +++ b/ifaces_test.go @@ -0,0 +1,16 @@ +package common + +import ( + "net" + "testing" +) + +func needsDialer(t *testing.T, d any) { + if _, ok := d.(Dialer); !ok { + t.Fatal("d is not a Dialer") + } +} + +func TestDialer(t *testing.T) { + needsDialer(t, &net.Dialer{}) +}