Black Lives Matter. Support the Equal Justice Initiative.

Source file src/crypto/rand/eagain.go

Documentation: crypto/rand

     1  // Copyright 2014 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
     6  // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
     7  
     8  package rand
     9  
    10  import (
    11  	"io/fs"
    12  	"syscall"
    13  )
    14  
    15  func init() {
    16  	isEAGAIN = unixIsEAGAIN
    17  }
    18  
    19  // unixIsEAGAIN reports whether err is a syscall.EAGAIN wrapped in a PathError.
    20  // See golang.org/issue/9205
    21  func unixIsEAGAIN(err error) bool {
    22  	if pe, ok := err.(*fs.PathError); ok {
    23  		if errno, ok := pe.Err.(syscall.Errno); ok && errno == syscall.EAGAIN {
    24  			return true
    25  		}
    26  	}
    27  	return false
    28  }
    29  

View as plain text