Documentation
¶
Index ¶
- Constants
- func IsAdmin() (bool, error)
- func IsWSL() bool
- func Nice() (int, error)
- func Renice(nice int) error
- func SameFile(fi1, fi2 FileInfo) bool
- func SameFiles(name1, name2 string) bool
- func SamePartition(fi1, fi2 FileInfo) bool
- func SamePartitions(name1, name2 string) bool
- func Supports(function SupportedType) bool
- type FileInfo
- type InvalidNiceError
- type NiceError
- type ReniceError
- type SupportedType
Constants ¶
const ( // MaxNice is the maximum value returned by Nice(). MaxNice = 19 // MinNice is the minimum value returned by Nice(). MinNice = -20 )
const ( IsAIX = runtime.GOOS == _aix IsAndroid = runtime.GOOS == _android IsDarwin = runtime.GOOS == _darwin IsDragonfly = runtime.GOOS == _dragonfly IsFreeBSD = runtime.GOOS == _freebsd IsIllumos = runtime.GOOS == _illumos IsIOS = runtime.GOOS == _ios IsJS = runtime.GOOS == _js IsLinux = runtime.GOOS == _linux IsNetBSD = runtime.GOOS == _netbsd IsOpenBSD = runtime.GOOS == _openbsd IsPlan9 = runtime.GOOS == _plan9 IsSolaris = runtime.GOOS == _solaris IsWasip1 = runtime.GOOS == _wasip1 IsWindows = runtime.GOOS == _windows )
const ( Is386 = runtime.GOARCH == _386 IsAmd64 = runtime.GOARCH == _amd64 IsArm = runtime.GOARCH == _arm IsArm64 = runtime.GOARCH == _arm64 IsLoong64 = runtime.GOARCH == _loong64 IsMips = runtime.GOARCH == _mips IsMips64 = runtime.GOARCH == _mips64 IsMips64le = runtime.GOARCH == _mips64le IsMipsle = runtime.GOARCH == _mipsle IsPpc64 = runtime.GOARCH == _ppc64 IsPpc64le = runtime.GOARCH == _ppc64le IsRiscv64 = runtime.GOARCH == _riscv64 IsS390x = runtime.GOARCH == _s390x IsWasm = runtime.GOARCH == _wasm )
Variables ¶
This section is empty.
Functions ¶
func IsAdmin ¶ added in v0.3.0
IsAdmin returns true if the user is root, or has Windows Administrator rights.
func IsWSL ¶ added in v0.3.0
func IsWSL() bool
IsWSL returns true if running under Windows Subsytem for Linux (WSL), otherwise false.
func Nice ¶ added in v0.2.0
Nice gets the CPU process priority. The return value is in a range from -20 (least nice), to 19 (most nice), even on non-Unix systems such as Windows, plan9, etc. If not supported by the operating system, -1 is returned.
func Renice ¶ added in v0.2.0
Renice sets the CPU process priority. The nice parameter can range from -20 (least nice), to 19 (most nice), even on non-Unix systems such as Windows, plan9, etc.
func SameFile ¶
SameFile reports whether fi1 and fi2 describe the same file. For example, on Unix this means that the Partition and inode fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SamePartition only applies to results returned by this package's Stat. It returns false in other cases.
func SameFiles ¶
SameFiles reports whether name1 and name2 are the same file. The function follow symlinks.
func SamePartition ¶ added in v0.4.0
SamePartition reports whether fi1 and fi2 describe files on the same Partition. For example, on Unix this means that the Partition fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SamePartition only applies to results returned by this package's Stat. It returns false in other cases.
func SamePartitions ¶ added in v0.4.0
SamePartitions reports whether name1 and name2 are files on the same Partition. The function follow symlinks.
func Supports ¶
func Supports(function SupportedType) bool
Supports returns whether function is supported by the operating system.
Types ¶
type FileInfo ¶
type FileInfo interface {
Name() string // base name of the file
Size() int64 // length in bytes for regular files; system-dependent for others
Mode() os.FileMode // file mode bits
ModTime() time.Time // last modified time
IsDir() bool // abbreviation for Mode().IsDir()
Sys() any // underlying data source
PartitionID() uint64 // unique disk partition ID
FileID() uint64 // unique file ID (on a specific partition)
Links() uint64 // number of hard links, or 0 if unsupported
ATime() time.Time // last accessed time, or 0 if unsupported
BTime() time.Time // birth (created) time, or 0 if unsupported
CTime() time.Time // last changed time, or 0 if unsupported
MTime() time.Time // last modified time (alias)
UID() uint64 // user ID, or 0 if unsupported
GID() uint64 // group ID, or 0 if unsupported
}
A FileInfo describes a file and is returned by Stat. See https://github.com/golang/go/blob/ad7a6f81/src/io/fs/fs.go#L158
func Lstat ¶
Lstat returns a FileInfo describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type [*PathError].
On Windows, if the file is a reparse point that is a surrogate for another named entity (such as a symbolic link or mounted folder), the returned FileInfo describes the reparse point, and makes no attempt to resolve it.
type InvalidNiceError ¶ added in v0.2.0
type InvalidNiceError struct {
// contains filtered or unexported fields
}
InvalidNiceError is returned when the niceness value passed by the user is invalid.
func (*InvalidNiceError) Error ¶ added in v0.2.0
func (e *InvalidNiceError) Error() string
type NiceError ¶ added in v0.2.0
type NiceError struct {
// contains filtered or unexported fields
}
NiceError is returned when system call failed.
type ReniceError ¶ added in v0.2.0
type ReniceError struct {
// contains filtered or unexported fields
}
ReniceError is returned when the system failed to set the OS's niceness level.
func (*ReniceError) Error ¶ added in v0.2.0
func (e *ReniceError) Error() string
type SupportedType ¶ added in v0.2.0
type SupportedType uint
SupportedType defines a bitmask that identifies if the OS supports specific fields, or not.
const ( // Links defines if FileInfo's Links() function is supported by the OS. // Links() returns the number of hard links to the file. Links SupportedType = 1 << iota // ATime defines if FileInfo's ATime() function is supported by the OS. // ATime() returns the time the file was last accessed. ATime // BTime defines if FileInfo's BTime() function is supported by the OS. // BTime() returns the time the file was created (or "birthed"). BTime // CTime defines if FileInfo's CTime() function is supported by the OS. // CTime() returns the time the file's metadata was last changed. CTime // UID defines if FileInfo's UID() function is supported by the OS. // UID() returns the user ID of the file's owner. UID // GID defines if FileInfo's GID() function is supported by the OS. // GID() returns the group ID of the file's group. GID )