You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
678 B

  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. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package socket
  6. import "syscall"
  7. var (
  8. errEAGAIN error = syscall.EAGAIN
  9. errEINVAL error = syscall.EINVAL
  10. errENOENT error = syscall.ENOENT
  11. )
  12. // errnoErr returns common boxed Errno values, to prevent allocations
  13. // at runtime.
  14. func errnoErr(errno syscall.Errno) error {
  15. switch errno {
  16. case 0:
  17. return nil
  18. case syscall.EAGAIN:
  19. return errEAGAIN
  20. case syscall.EINVAL:
  21. return errEINVAL
  22. case syscall.ENOENT:
  23. return errENOENT
  24. }
  25. return errno
  26. }