blob: 93dff918028277371c110782ab1d0c9edb90b1e1 [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
7package socket
8
9import "syscall"
10
11var (
12 errEAGAIN error = syscall.EAGAIN
13 errEINVAL error = syscall.EINVAL
14 errENOENT error = syscall.ENOENT
15)
16
17// errnoErr returns common boxed Errno values, to prevent allocations
18// at runtime.
19func errnoErr(errno syscall.Errno) error {
20 switch errno {
21 case 0:
22 return nil
23 case syscall.EAGAIN:
24 return errEAGAIN
25 case syscall.EINVAL:
26 return errEINVAL
27 case syscall.ENOENT:
28 return errENOENT
29 }
30 return errno
31}