aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod5
-rw-r--r--go.sum2
-rw-r--r--pipeln.go11
-rw-r--r--pipeln_test.go9
4 files changed, 10 insertions, 17 deletions
diff --git a/go.mod b/go.mod
index 1b0897c..ec4c365 100644
--- a/go.mod
+++ b/go.mod
@@ -2,9 +2,6 @@ module go.awhk.org/pipeln
go 1.18
-require (
- go.awhk.org/core v0.2.0
- golang.org/x/sys v0.0.0-20220730100132-1609e554cd39
-)
+require go.awhk.org/core v0.2.0
require github.com/google/go-cmp v0.5.8 // indirect
diff --git a/go.sum b/go.sum
index 2283251..45a48a3 100644
--- a/go.sum
+++ b/go.sum
@@ -2,5 +2,3 @@ github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
go.awhk.org/core v0.2.0 h1:EEzFUh+0okmVdSvdqB1XRm6AsD1hniSeY1wLNHjo+lk=
go.awhk.org/core v0.2.0/go.mod h1:5C9oWobMcQLGj+rcfvAvSiGrp/vslOD0eUiwYymTaQI=
-golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk=
-golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/pipeln.go b/pipeln.go
index a05a473..ca130e2 100644
--- a/pipeln.go
+++ b/pipeln.go
@@ -5,8 +5,7 @@ package pipeln
import (
"context"
"net"
-
- "golang.org/x/sys/unix"
+ "syscall"
)
// PipeListenerDialer can be used to simulate client-server interaction
@@ -26,7 +25,7 @@ func (ln *PipeListenerDialer) Accept() (net.Conn, error) {
case conn := <-ln.conns:
return conn, nil
case <-ln.done:
- return nil, unix.EINVAL
+ return nil, syscall.EINVAL
}
}
@@ -38,7 +37,7 @@ func (ln *PipeListenerDialer) Addr() net.Addr {
// See net.Listener.Close for more details.
func (ln *PipeListenerDialer) Close() error {
if !ln.ok {
- return unix.EINVAL
+ return syscall.EINVAL
}
close(ln.done)
ln.ok = false
@@ -53,14 +52,14 @@ func (ln *PipeListenerDialer) Dial(_, addr string) (net.Conn, error) {
// DialContext is a dummy wrapper around Dial.
func (ln *PipeListenerDialer) DialContext(ctx context.Context, _, addr string) (net.Conn, error) {
if addr != ln.addr {
- return nil, unix.EINVAL
+ return nil, syscall.EINVAL
}
s, c := net.Pipe()
select {
case ln.conns <- s:
return c, nil
case <-ln.done:
- return nil, unix.ECONNREFUSED
+ return nil, syscall.ECONNREFUSED
case <-ctx.Done():
return nil, ctx.Err()
}
diff --git a/pipeln_test.go b/pipeln_test.go
index dcbeb22..3b822b2 100644
--- a/pipeln_test.go
+++ b/pipeln_test.go
@@ -5,10 +5,9 @@ package pipeln
import (
"context"
"net/http"
+ "syscall"
"testing"
- "golang.org/x/sys/unix"
-
"go.awhk.org/core"
)
@@ -33,18 +32,18 @@ func Test(s *testing.T) {
t.Run("Address Mismatch", func(t *core.T) {
_, err := client.Get("http://other-test/endpoint")
- t.AssertErrorIs(unix.EINVAL, err)
+ t.AssertErrorIs(syscall.EINVAL, err)
})
srv.Shutdown(context.Background())
t.Run("Remote Connection Closed", func(t *core.T) {
_, err := client.Get("http://test/endpoint")
- t.AssertErrorIs(unix.ECONNREFUSED, err)
+ t.AssertErrorIs(syscall.ECONNREFUSED, err)
})
t.Run("Already-closed Listener", func(t *core.T) {
srv = http.Server{Handler: mux}
- t.AssertErrorIs(unix.EINVAL, srv.Serve(ln))
+ t.AssertErrorIs(syscall.EINVAL, srv.Serve(ln))
})
}