punix

package
v0.4.81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2023 License: ISC Imports: 8 Imported by: 1

Documentation

Overview

punix has functions to examine unix.Errno errors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errno

func Errno(err error) (errnoValue unix.Errno)

Errno scans an error chain for a unix.Errno type. Errno returns unix.Errno 0x0 if none exists. Note: unix.Errno.Error has value receiver. Errno checks:

Errno(nil) == 0 → true.
if errno != 0 {…
int(errno) provides the numeric value.
 if errno == unix.ENOENT…
 fmt.Printf("%v", errno) → state not recoverable
 fmt.Printf("0x%x", int(errno)) → 0x68

func ErrnoError

func ErrnoError(err error, includeError ...bool) (errnoString string)

ErrnoError gets the errno interpretation if the error chain does contain a unix.Errno type. if includeError is true, the error chain’s error message is prepended. if includeError is true and err is nil "OK" is returned if includeError is false or missing and no errno exists, the empty string is returned

func ErrorNumberString added in v0.4.36

func ErrorNumberString(err error, label string) (errnoNumericString string)

ErrorNumberString returns the errno number as a string if the err error chain has a non-zero syscall.Errno error.

  • returned string is similar to: "label: 5 0x5"
  • if label is empty string, no label is returned
  • if no syscall.Errno is found or it is zero, the empty string is returned

func IsConnectionRefused

func IsConnectionRefused(err error) (isConnectionRefused bool)

IsConnectionRefused searches the error chsin of err for unix.ECONNREFUSED net.Dialer errors for closed socket

func IsENOENT

func IsENOENT(err error) (isENOENT bool)

IsENOENT returns true if the root cause of err is file not found. Can be used with os.Open* file not found

func OsVersion added in v0.4.64

func OsVersion() (version string, hasVersion bool, err error)

OsVersion for linux returns version: "Linux 5.15.0-56-generic"

func Processor added in v0.4.74

func Processor() (model string, err error)

Processor returns human readable string like "Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL