gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/internal/poll/errno_windows.go (about)

     1  // Copyright 2019 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 windows
     6  // +build windows
     7  
     8  package poll
     9  
    10  import "syscall"
    11  
    12  // Do the interface allocations only once for common
    13  // Errno values.
    14  
    15  var (
    16  	errERROR_IO_PENDING error = syscall.Errno(syscall.ERROR_IO_PENDING)
    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.ERROR_IO_PENDING:
    26  		return errERROR_IO_PENDING
    27  	}
    28  	// TODO: add more here, after collecting data on the common
    29  	// error values see on Windows. (perhaps when running
    30  	// all.bat?)
    31  	return e
    32  }