Feat: Dialer interface (why is this not in stdlib)
This commit is contained in:
parent
f2f4b51076
commit
513277750a
8
ifaces.go
Normal file
8
ifaces.go
Normal file
@ -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)
|
||||||
|
}
|
16
ifaces_test.go
Normal file
16
ifaces_test.go
Normal file
@ -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{})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user