mirror of
https://github.com/golang/net.git
synced 2026-03-31 18:37:08 +09:00
This is a counterpart of https://go-review.googlesource.com/37039. This change introduces a package that provides a portable interface for the manipulation of sockets using either syscall.Conn and syscall.RawConn interfaces or the internal/netreflect package appropriately. The package ensures that a package using this works with all supported versions of the Go standard library. Updates golang/go#19051. Change-Id: Ib72ea369e6839e77fed6e35b9aedc364e73c51cb Reviewed-on: https://go-review.googlesource.com/37035 Reviewed-by: Ian Lance Taylor <iant@golang.org>
27 lines
588 B
Go
27 lines
588 B
Go
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package socket
|
|
|
|
import "syscall"
|
|
|
|
var (
|
|
errERROR_IO_PENDING error = syscall.ERROR_IO_PENDING
|
|
errEINVAL error = syscall.EINVAL
|
|
)
|
|
|
|
// errnoErr returns common boxed Errno values, to prevent allocations
|
|
// at runtime.
|
|
func errnoErr(errno syscall.Errno) error {
|
|
switch errno {
|
|
case 0:
|
|
return nil
|
|
case syscall.ERROR_IO_PENDING:
|
|
return errERROR_IO_PENDING
|
|
case syscall.EINVAL:
|
|
return errEINVAL
|
|
}
|
|
return errno
|
|
}
|