error_unix.go raw
1 // 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 //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
6
7 package socket
8
9 import "syscall"
10
11 var (
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.
19 func 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 }
32