Browse Source

rwcancel: no-op builds for windows and darwin

This lets us include the package on those platforms in a
followup commit where we split out a conn package from device.
It also lets us run `go test ./...` when developing on macOS.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
David Crawshaw 3 months ago
parent
commit
224bc9e60c
4 changed files with 17 additions and 2 deletions
  1. 2
    0
      rwcancel/fdset.go
  2. 4
    0
      rwcancel/rwcancel.go
  3. 8
    0
      rwcancel/rwcancel_windows.go
  4. 3
    2
      rwcancel/select_default.go

+ 2
- 0
rwcancel/fdset.go View File

@@ -1,3 +1,5 @@
1
+// +build !windows
2
+
1 3
 /* SPDX-License-Identifier: MIT
2 4
  *
3 5
  * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.

+ 4
- 0
rwcancel/rwcancel.go View File

@@ -1,8 +1,12 @@
1
+// +build !windows
2
+
1 3
 /* SPDX-License-Identifier: MIT
2 4
  *
3 5
  * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
4 6
  */
5 7
 
8
+// Package rwcancel implements cancelable read/write operations on
9
+// a file descriptor.
6 10
 package rwcancel
7 11
 
8 12
 import (

+ 8
- 0
rwcancel/rwcancel_windows.go View File

@@ -0,0 +1,8 @@
1
+// SPDX-License-Identifier: MIT
2
+
3
+package rwcancel
4
+
5
+type RWCancel struct {
6
+}
7
+
8
+func (*RWCancel) Cancel() {}

+ 3
- 2
rwcancel/select_default.go View File

@@ -1,4 +1,4 @@
1
-// +build !linux
1
+// +build !linux,!windows
2 2
 
3 3
 /* SPDX-License-Identifier: MIT
4 4
  *
@@ -10,5 +10,6 @@ package rwcancel
10 10
 import "golang.org/x/sys/unix"
11 11
 
12 12
 func unixSelect(nfd int, r *unix.FdSet, w *unix.FdSet, e *unix.FdSet, timeout *unix.Timeval) error {
13
-	return unix.Select(nfd, r, w, e, timeout)
13
+	_, err := unix.Select(nfd, r, w, e, timeout)
14
+	return err
14 15
 }

Loading…
Cancel
Save