github.com/LanceLRQ/deer-common@v0.0.9-0.20210319081233-e8222ac018a8/sandbox/forkexec/syscall_unix.go (about) 1 // Copyright 2009 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 linux 6 7 package forkexec 8 9 import "syscall" 10 11 // Do the interface allocations only once for common 12 // Errno values. 13 var ( 14 errEAGAIN error = syscall.EAGAIN 15 errEINVAL error = syscall.EINVAL 16 errENOENT error = syscall.ENOENT 17 ) 18 19 // errnoErr returns common boxed Errno values, to prevent 20 // allocations at runtime. 21 func errnoErr(e syscall.Errno) error { 22 switch e { 23 case 0: 24 return nil 25 case syscall.EAGAIN: 26 return errEAGAIN 27 case syscall.EINVAL: 28 return errEINVAL 29 case syscall.ENOENT: 30 return errENOENT 31 } 32 return e 33 }