Namespace: go.std.os
v1.0Contents
Summary
Provides a low-level interface to the os package.
Package os provides a platform-independent interface to operating system
functionality. The design is Unix-like, although the error handling is
Go-like; failing calls return values of type error rather than error numbers.
Often, more information is available within the error. For example,
if a call that takes a file name fails, such as Open or Stat, the error
will include the failing file name when printed and will be of type
*PathError, which may be unpacked for more information.
The os interface is intended to be uniform across all operating systems.
Features not generally available appear in the system-specific package syscall.
Here is a simple example, opening a file and reading some of it.
file, err := os.Open("file.go") // For read access.
if err != nil {
log.Fatal(err)
}
If the open fails, the error string will be self-explanatory, like
open file.go: no such file or directory
The file's data can then be read into a slice of bytes. Read and
Write take their byte counts from the length of the argument slice.
data := make([]byte, 100)
count, err := file.Read(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("read %d bytes: %q\n", count, data[:count])
Note: The maximum number of concurrent operations on a File may be limited by
the OS or the system. The number should be high, but exceeding it may degrade
performance or cause other issues.
Index
- *File
- *LinkError
- *ProcAttr
- *Process
- *ProcessState
- *SyscallError
- Args
- Chdir
- Chmod
- Chown
- Chtimes
- Clearenv
- Create
- CreateTemp
- DevNull
- DirFS
- Environ
- ErrClosed
- ErrDeadlineExceeded
- ErrExist
- ErrInvalid
- ErrNoDeadline
- ErrNotExist
- ErrPermission
- ErrProcessDone
- Executable
- Exit
- ExpandEnv
- File
- FindProcess
- Getegid
- Getenv
- Geteuid
- Getgid
- Getgroups
- Getpagesize
- Getpid
- Getppid
- Getuid
- Getwd
- Hostname
- Interrupt
- IsExist
- IsNotExist
- IsPathSeparator
- IsPermission
- IsTimeout
- Kill
- Lchown
- Link
- LinkError
- LookupEnv
- Lstat
- Mkdir
- MkdirAll
- MkdirTemp
- ModeAppend
- ModeCharDevice
- ModeDevice
- ModeDir
- ModeExclusive
- ModeIrregular
- ModeNamedPipe
- ModePerm
- ModeSetgid
- ModeSetuid
- ModeSocket
- ModeSticky
- ModeSymlink
- ModeTemporary
- ModeType
- NewFile
- NewSyscallError
- O_APPEND
- O_CREATE
- O_EXCL
- O_RDONLY
- O_RDWR
- O_SYNC
- O_TRUNC
- O_WRONLY
- Open
- OpenFile
- PathListSeparator
- PathSeparator
- Pipe
- ProcAttr
- Process
- ProcessState
- ReadDir
- ReadFile
- Readlink
- Remove
- RemoveAll
- Rename
- SEEK_CUR
- SEEK_END
- SEEK_SET
- SameFile
- Setenv
- Signal
- StartProcess
- Stat
- Stderr
- Stdin
- Stdout
- Symlink
- SyscallError
- TempDir
- Truncate
- Unsetenv
- UserCacheDir
- UserConfigDir
- UserHomeDir
- WriteFile
- arrayOfFile
- arrayOfLinkError
- arrayOfProcAttr
- arrayOfProcess
- arrayOfProcessState
- arrayOfSignal
- arrayOfSyscallError
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
DevNull
String v1.0DevNull is the name of the operating system's “null device.”
On Unix-like systems, it is "/dev/null"; on Windows, "NUL".
-
O_APPEND
Int v1.0The remaining values may be or'ed in to control behavior.
-
O_CREATE
Int v1.0create a new file if none exists.
-
O_EXCL
Int v1.0used with O_CREATE, file must not exist.
-
O_RDONLY
Int v1.0Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified.
-
O_RDWR
Int v1.0open the file read-write.
-
O_SYNC
Int v1.0open for synchronous I/O.
-
O_TRUNC
Int v1.0truncate regular writable file when opened.
-
O_WRONLY
Int v1.0open the file write-only.
-
PathListSeparator
Char v1.0OS-specific path list separator
-
PathSeparator
Char v1.0OS-specific path separator
-
SEEK_CUR
Int v1.0seek relative to the current offset
-
SEEK_END
Int v1.0seek relative to the end
-
SEEK_SET
Int v1.0seek relative to the origin of the file
Variables
-
Args
Var v1.0Args hold the command-line arguments, starting with the program name.
-
ErrClosed
Var v1.0"file already closed"
-
ErrDeadlineExceeded
Var v1.0"i/o timeout"
-
ErrExist
Var v1.0"file already exists"
-
ErrInvalid
Var v1.0ErrInvalid indicates an invalid argument.
Methods on File will return this error when the receiver is nil.
-
ErrNoDeadline
Var v1.0"file type does not support deadline"
-
ErrNotExist
Var v1.0"file does not exist"
-
ErrPermission
Var v1.0"permission denied"
-
ErrProcessDone
Var v1.0ErrProcessDone indicates a Process has finished.
-
Interrupt
Var v1.0The only signal values guaranteed to be present in the os package on all
systems are os.Interrupt (send the process an interrupt) and os.Kill (force
the process to exit). On Windows, sending os.Interrupt to a process with
os.Process.Signal is not implemented; it will return an error instead of
sending a signal.
-
Kill
Var v1.0The only signal values guaranteed to be present in the os package on all
systems are os.Interrupt (send the process an interrupt) and os.Kill (force
the process to exit). On Windows, sending os.Interrupt to a process with
os.Process.Signal is not implemented; it will return an error instead of
sending a signal.
-
ModeAppend
GoObject v1.0a: append-only
-
ModeCharDevice
GoObject v1.0c: Unix character device, when ModeDevice is set
-
ModeDevice
GoObject v1.0D: device file
-
ModeDir
GoObject v1.0The single letters are the abbreviations
used by the String method's formatting.
-
ModeExclusive
GoObject v1.0l: exclusive use
-
ModeIrregular
GoObject v1.0?: non-regular file; nothing else is known about this file
-
ModeNamedPipe
GoObject v1.0p: named pipe (FIFO)
-
ModePerm
GoObject v1.0Unix permission bits, 0o777
-
ModeSetgid
GoObject v1.0g: setgid
-
ModeSetuid
GoObject v1.0u: setuid
-
ModeSocket
GoObject v1.0S: Unix domain socket
-
ModeSticky
GoObject v1.0t: sticky
-
ModeSymlink
GoObject v1.0L: symbolic link
-
ModeTemporary
GoObject v1.0T: temporary file; Plan 9 only
-
ModeType
GoObject v1.0Mask for the type bits. For regular files, none will be set.
-
Stderr
Var v1.0Stdin, Stdout, and Stderr are open Files pointing to the standard input,
standard output, and standard error file descriptors.
Note that the Go runtime writes to standard error for panics and crashes;
closing Stderr may cause those messages to go elsewhere, perhaps
to a file opened later.
-
Stdin
Var v1.0Stdin, Stdout, and Stderr are open Files pointing to the standard input,
standard output, and standard error file descriptors.
Note that the Go runtime writes to standard error for panics and crashes;
closing Stderr may cause those messages to go elsewhere, perhaps
to a file opened later.
-
Stdout
Var v1.0Stdin, Stdout, and Stderr are open Files pointing to the standard input,
standard output, and standard error file descriptors.
Note that the Go runtime writes to standard error for panics and crashes;
closing Stderr may cause those messages to go elsewhere, perhaps
to a file opened later.
Functions, Macros, and Special Forms
-
Chdir
Function v1.0(Chdir dir)
Chdir changes the current working directory to the named directory.
If there is an error, it will be of type *PathError.
Go input arguments: (dir string)
Go returns: error
Joker input arguments: [^String dir]
Joker returns: ^Error -
Chmod
Function v1.0(Chmod name mode)
Chmod changes the mode of the named file to mode.
If the file is a symbolic link, it changes the mode of the link's target.
If there is an error, it will be of type *PathError.
A different subset of the mode bits are used, depending on the
operating system.
On Unix, the mode's permission bits, ModeSetuid, ModeSetgid, and
ModeSticky are used.
On Windows, only the 0200 bit (owner writable) of mode is used; it
controls whether the file's read-only attribute is set or cleared.
The other bits are currently unused. For compatibility with Go 1.12
and earlier, use a non-zero mode. Use mode 0400 for a read-only
file and 0600 for a readable+writable file.
On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive,
and ModeTemporary are used.
Go input arguments: (name string, mode io/fs.FileMode)
Go returns: error
Joker input arguments: [^String name, ^go.std.io.fs/FileMode mode]
Joker returns: ^Error -
Chown
Function v1.0(Chown name uid gid)
Chown changes the numeric uid and gid of the named file.
If the file is a symbolic link, it changes the uid and gid of the link's target.
A uid or gid of -1 means to not change that value.
If there is an error, it will be of type *PathError.
On Windows or Plan 9, Chown always returns the syscall.EWINDOWS or
EPLAN9 error, wrapped in *PathError.
Go input arguments: (name string, uid int, gid int)
Go returns: error
Joker input arguments: [^String name, ^Int uid, ^Int gid]
Joker returns: ^Error -
Chtimes
Function v1.0(Chtimes name atime mtime)
Chtimes changes the access and modification times of the named
file, similar to the Unix utime() or utimes() functions.
The underlying filesystem may truncate or round the values to a
less precise time unit.
If there is an error, it will be of type *PathError.
Go input arguments: (name string, atime time.Time, mtime time.Time)
Go returns: error
Joker input arguments: [^String name, ^go.std.time/Time atime, ^go.std.time/Time mtime]
Joker returns: ^Error -
Clearenv
Function v1.0(Clearenv)
Clearenv deletes all environment variables.
Joker input arguments: [] -
Create
Function v1.0(Create name)
Create creates or truncates the named file. If the file already exists,
it is truncated. If the file does not exist, it is created with mode 0666
(before umask). If successful, methods on the returned File can
be used for I/O; the associated file descriptor has mode O_RDWR.
If there is an error, it will be of type *PathError.
Go input arguments: (name string)
Go returns: (*File, error)
Joker input arguments: [^String name]
Joker returns: [^*File, ^Error] -
CreateTemp
Function v1.0(CreateTemp dir pattern)
CreateTemp creates a new temporary file in the directory dir,
opens the file for reading and writing, and returns the resulting file.
The filename is generated by taking pattern and adding a random string to the end.
If pattern includes a "*", the random string replaces the last "*".
If dir is the empty string, CreateTemp uses the default directory for temporary files, as returned by TempDir.
Multiple programs or goroutines calling CreateTemp simultaneously will not choose the same file.
The caller can use the file's Name method to find the pathname of the file.
It is the caller's responsibility to remove the file when it is no longer needed.
Go input arguments: (dir string, pattern string)
Go returns: (*File, error)
Joker input arguments: [^String dir, ^String pattern]
Joker returns: [^*File, ^Error] -
DirFS
Function v1.0(DirFS dir)
DirFS returns a file system (an fs.FS) for the tree of files rooted at the directory dir.
Note that DirFS("/prefix") only guarantees that the Open calls it makes to the
operating system will begin with "/prefix": DirFS("/prefix").Open("file") is the
same as os.Open("/prefix/file"). So if /prefix/file is a symbolic link pointing outside
the /prefix tree, then using DirFS does not stop the access any more than using
os.Open does. Additionally, the root of the fs.FS returned for a relative path,
DirFS("prefix"), will be affected by later calls to Chdir. DirFS is therefore not
a general substitute for a chroot-style security mechanism when the directory tree
contains arbitrary content.
The directory dir must not be "".
The result implements fs.StatFS.
Go input arguments: (dir string)
Go returns: io/fs.FS
Joker input arguments: [^String dir]
Joker returns: ^go.std.io.fs/FS -
Environ
Function v1.0(Environ)
Environ returns a copy of strings representing the environment,
in the form "key=value".
Go returns: []string
Joker input arguments: []
Joker returns: ^arrayOfString -
Executable
Function v1.0(Executable)
Executable returns the path name for the executable that started
the current process. There is no guarantee that the path is still
pointing to the correct executable. If a symlink was used to start
the process, depending on the operating system, the result might
be the symlink or the path it pointed to. If a stable result is
needed, path/filepath.EvalSymlinks might help.
Executable returns an absolute path unless an error occurred.
The main use case is finding resources located relative to an
executable.
Go returns: (string, error)
Joker input arguments: []
Joker returns: [^String, ^Error] -
Exit
Function v1.0(Exit code)
Exit causes the current program to exit with the given status code.
Conventionally, code zero indicates success, non-zero an error.
The program terminates immediately; deferred functions are not run.
For portability, the status code should be in the range [0, 125].
Go input arguments: (code int)
Joker input arguments: [^Int code] -
ExpandEnv
Function v1.0(ExpandEnv s)
ExpandEnv replaces ${var} or $var in the string according to the values
of the current environment variables. References to undefined
variables are replaced by the empty string.
Go input arguments: (s string)
Go returns: string
Joker input arguments: [^String s]
Joker returns: ^String -
FindProcess
Function v1.0(FindProcess pid)
FindProcess looks for a running process by its pid.
The Process it returns can be used to obtain information
about the underlying operating system process.
On Unix systems, FindProcess always succeeds and returns a Process
for the given pid, regardless of whether the process exists.
Go input arguments: (pid int)
Go returns: (*Process, error)
Joker input arguments: [^Int pid]
Joker returns: [^*Process, ^Error] -
Getegid
Function v1.0(Getegid)
Getegid returns the numeric effective group id of the caller.
On Windows, it returns -1.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getenv
Function v1.0(Getenv key)
Getenv retrieves the value of the environment variable named by the key.
It returns the value, which will be empty if the variable is not present.
To distinguish between an empty value and an unset value, use LookupEnv.
Go input arguments: (key string)
Go returns: string
Joker input arguments: [^String key]
Joker returns: ^String -
Geteuid
Function v1.0(Geteuid)
Geteuid returns the numeric effective user id of the caller.
On Windows, it returns -1.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getgid
Function v1.0(Getgid)
Getgid returns the numeric group id of the caller.
On Windows, it returns -1.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getgroups
Function v1.0(Getgroups)
Getgroups returns a list of the numeric ids of groups that the caller belongs to.
On Windows, it returns syscall.EWINDOWS. See the os/user package
for a possible alternative.
Go returns: ([]int, error)
Joker input arguments: []
Joker returns: [^arrayOfInt, ^Error] -
Getpagesize
Function v1.0(Getpagesize)
Getpagesize returns the underlying system's memory page size.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getpid
Function v1.0(Getpid)
Getpid returns the process id of the caller.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getppid
Function v1.0(Getppid)
Getppid returns the process id of the caller's parent.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getuid
Function v1.0(Getuid)
Getuid returns the numeric user id of the caller.
On Windows, it returns -1.
Go returns: int
Joker input arguments: []
Joker returns: ^Int -
Getwd
Function v1.0(Getwd)
Getwd returns a rooted path name corresponding to the
current directory. If the current directory can be
reached via multiple paths (due to symbolic links),
Getwd may return any one of them.
Go returns: (dir string, err error)
Joker input arguments: []
Joker returns: [^String dir, ^Error err] -
Hostname
Function v1.0(Hostname)
Hostname returns the host name reported by the kernel.
Go returns: (name string, err error)
Joker input arguments: []
Joker returns: [^String name, ^Error err] -
IsExist
Function v1.0(IsExist err)
IsExist returns a boolean indicating whether the error is known to report
that a file or directory already exists. It is satisfied by ErrExist as
well as some syscall errors.
This function predates errors.Is. It only supports errors returned by
the os package. New code should use errors.Is(err, fs.ErrExist).
Go input arguments: (err error)
Go returns: bool
Joker input arguments: [^Error err]
Joker returns: ^Boolean -
IsNotExist
Function v1.0(IsNotExist err)
IsNotExist returns a boolean indicating whether the error is known to
report that a file or directory does not exist. It is satisfied by
ErrNotExist as well as some syscall errors.
This function predates errors.Is. It only supports errors returned by
the os package. New code should use errors.Is(err, fs.ErrNotExist).
Go input arguments: (err error)
Go returns: bool
Joker input arguments: [^Error err]
Joker returns: ^Boolean -
IsPathSeparator
Function v1.0(IsPathSeparator c)
IsPathSeparator reports whether c is a directory separator character.
Go input arguments: (c uint8)
Go returns: bool
Joker input arguments: [^Int c]
Joker returns: ^Boolean -
IsPermission
Function v1.0(IsPermission err)
IsPermission returns a boolean indicating whether the error is known to
report that permission is denied. It is satisfied by ErrPermission as well
as some syscall errors.
This function predates errors.Is. It only supports errors returned by
the os package. New code should use errors.Is(err, fs.ErrPermission).
Go input arguments: (err error)
Go returns: bool
Joker input arguments: [^Error err]
Joker returns: ^Boolean -
IsTimeout
Function v1.0(IsTimeout err)
IsTimeout returns a boolean indicating whether the error is known
to report that a timeout occurred.
This function predates errors.Is, and the notion of whether an
error indicates a timeout can be ambiguous. For example, the Unix
error EWOULDBLOCK sometimes indicates a timeout and sometimes does not.
New code should use errors.Is with a value appropriate to the call
returning the error, such as os.ErrDeadlineExceeded.
Go input arguments: (err error)
Go returns: bool
Joker input arguments: [^Error err]
Joker returns: ^Boolean -
Lchown
Function v1.0(Lchown name uid gid)
Lchown changes the numeric uid and gid of the named file.
If the file is a symbolic link, it changes the uid and gid of the link itself.
If there is an error, it will be of type *PathError.
On Windows, it always returns the syscall.EWINDOWS error, wrapped
in *PathError.
Go input arguments: (name string, uid int, gid int)
Go returns: error
Joker input arguments: [^String name, ^Int uid, ^Int gid]
Joker returns: ^Error -
Link
Function v1.0(Link oldname newname)
Link creates newname as a hard link to the oldname file.
If there is an error, it will be of type *LinkError.
Go input arguments: (oldname string, newname string)
Go returns: error
Joker input arguments: [^String oldname, ^String newname]
Joker returns: ^Error -
LookupEnv
Function v1.0(LookupEnv key)
LookupEnv retrieves the value of the environment variable named
by the key. If the variable is present in the environment the
value (which may be empty) is returned and the boolean is true.
Otherwise the returned value will be empty and the boolean will
be false.
Go input arguments: (key string)
Go returns: (string, bool)
Joker input arguments: [^String key]
Joker returns: [^String, ^Boolean] -
Lstat
Function v1.0(Lstat name)
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.
Go input arguments: (name string)
Go returns: (io/fs.FileInfo, error)
Joker input arguments: [^String name]
Joker returns: [^go.std.io.fs/FileInfo, ^Error] -
Mkdir
Function v1.0(Mkdir name perm)
Mkdir creates a new directory with the specified name and permission
bits (before umask).
If there is an error, it will be of type *PathError.
Go input arguments: (name string, perm io/fs.FileMode)
Go returns: error
Joker input arguments: [^String name, ^go.std.io.fs/FileMode perm]
Joker returns: ^Error -
MkdirAll
Function v1.0(MkdirAll path perm)
MkdirAll creates a directory named path,
along with any necessary parents, and returns nil,
or else returns an error.
The permission bits perm (before umask) are used for all
directories that MkdirAll creates.
If path is already a directory, MkdirAll does nothing
and returns nil.
Go input arguments: (path string, perm io/fs.FileMode)
Go returns: error
Joker input arguments: [^String path, ^go.std.io.fs/FileMode perm]
Joker returns: ^Error -
MkdirTemp
Function v1.0(MkdirTemp dir pattern)
MkdirTemp creates a new temporary directory in the directory dir
and returns the pathname of the new directory.
The new directory's name is generated by adding a random string to the end of pattern.
If pattern includes a "*", the random string replaces the last "*" instead.
If dir is the empty string, MkdirTemp uses the default directory for temporary files, as returned by TempDir.
Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory.
It is the caller's responsibility to remove the directory when it is no longer needed.
Go input arguments: (dir string, pattern string)
Go returns: (string, error)
Joker input arguments: [^String dir, ^String pattern]
Joker returns: [^String, ^Error] -
NewFile
Function v1.0(NewFile fd name)
NewFile returns a new File with the given file descriptor and
name. The returned value will be nil if fd is not a valid file
descriptor. On Unix systems, if the file descriptor is in
non-blocking mode, NewFile will attempt to return a pollable File
(one for which the SetDeadline methods work).
After passing it to NewFile, fd may become invalid under the same
conditions described in the comments of the Fd method, and the same
constraints apply.
Go input arguments: (fd uintptr, name string)
Go returns: *File
Joker input arguments: [^Number fd, ^String name]
Joker returns: ^*File -
NewSyscallError
Function v1.0(NewSyscallError syscall err)
NewSyscallError returns, as an error, a new SyscallError
with the given system call name and error details.
As a convenience, if err is nil, NewSyscallError returns nil.
Go input arguments: (syscall string, err error)
Go returns: error
Joker input arguments: [^String syscall, ^Error err]
Joker returns: ^Error -
Open
Function v1.0(Open name)
Open opens the named file for reading. If successful, methods on
the returned file can be used for reading; the associated file
descriptor has mode O_RDONLY.
If there is an error, it will be of type *PathError.
Go input arguments: (name string)
Go returns: (*File, error)
Joker input arguments: [^String name]
Joker returns: [^*File, ^Error] -
OpenFile
Function v1.0(OpenFile name flag perm)
OpenFile is the generalized open call; most users will use Open
or Create instead. It opens the named file with specified flag
(O_RDONLY etc.). If the file does not exist, and the O_CREATE flag
is passed, it is created with mode perm (before umask). If successful,
methods on the returned File can be used for I/O.
If there is an error, it will be of type *PathError.
Go input arguments: (name string, flag int, perm io/fs.FileMode)
Go returns: (*File, error)
Joker input arguments: [^String name, ^Int flag, ^go.std.io.fs/FileMode perm]
Joker returns: [^*File, ^Error] -
Pipe
Function v1.0(Pipe)
Pipe returns a connected pair of Files; reads from r return bytes written to w.
It returns the files and an error, if any.
Go returns: (r *File, w *File, err error)
Joker input arguments: []
Joker returns: [^*File r, ^*File w, ^Error err] -
ReadDir
Function v1.0(ReadDir name)
ReadDir reads the named directory,
returning all its directory entries sorted by filename.
If an error occurs reading the directory,
ReadDir returns the entries it was able to read before the error,
along with the error.
Go input arguments: (name string)
Go returns: ([]io/fs.DirEntry, error)
Joker input arguments: [^String name]
Joker returns: [^go.std.io.fs/arrayOfDirEntry, ^Error] -
ReadFile
Function v1.0(ReadFile name)
ReadFile reads the named file and returns the contents.
A successful call returns err == nil, not err == EOF.
Because ReadFile reads the whole file, it does not treat an EOF from Read
as an error to be reported.
Go input arguments: (name string)
Go returns: ([]byte, error)
Joker input arguments: [^String name]
Joker returns: [^arrayOfByte, ^Error] -
Readlink
Function v1.0(Readlink name)
Readlink returns the destination of the named symbolic link.
If there is an error, it will be of type *PathError.
Go input arguments: (name string)
Go returns: (string, error)
Joker input arguments: [^String name]
Joker returns: [^String, ^Error] -
Remove
Function v1.0(Remove name)
Remove removes the named file or (empty) directory.
If there is an error, it will be of type *PathError.
Go input arguments: (name string)
Go returns: error
Joker input arguments: [^String name]
Joker returns: ^Error -
RemoveAll
Function v1.0(RemoveAll path)
RemoveAll removes path and any children it contains.
It removes everything it can but returns the first error
it encounters. If the path does not exist, RemoveAll
returns nil (no error).
If there is an error, it will be of type *PathError.
Go input arguments: (path string)
Go returns: error
Joker input arguments: [^String path]
Joker returns: ^Error -
Rename
Function v1.0(Rename oldpath newpath)
Rename renames (moves) oldpath to newpath.
If newpath already exists and is not a directory, Rename replaces it.
OS-specific restrictions may apply when oldpath and newpath are in different directories.
If there is an error, it will be of type *LinkError.
Go input arguments: (oldpath string, newpath string)
Go returns: error
Joker input arguments: [^String oldpath, ^String newpath]
Joker returns: ^Error -
SameFile
Function v1.0(SameFile fi1 fi2)
SameFile reports whether fi1 and fi2 describe the same file.
For example, on Unix this means that the device and inode fields
of the two underlying structures are identical; on other systems
the decision may be based on the path names.
SameFile only applies to results returned by this package's Stat.
It returns false in other cases.
Go input arguments: (fi1 io/fs.FileInfo, fi2 io/fs.FileInfo)
Go returns: bool
Joker input arguments: [^go.std.io.fs/FileInfo fi1, ^go.std.io.fs/FileInfo fi2]
Joker returns: ^Boolean -
Setenv
Function v1.0(Setenv key value)
Setenv sets the value of the environment variable named by the key.
It returns an error, if any.
Go input arguments: (key string, value string)
Go returns: error
Joker input arguments: [^String key, ^String value]
Joker returns: ^Error -
StartProcess
Function v1.0(StartProcess name argv attr)
StartProcess starts a new process with the program, arguments and attributes
specified by name, argv and attr. The argv slice will become os.Args in the
new process, so it normally starts with the program name.
If the calling goroutine has locked the operating system thread
with runtime.LockOSThread and modified any inheritable OS-level
thread state (for example, Linux or Plan 9 name spaces), the new
process will inherit the caller's thread state.
StartProcess is a low-level interface. The os/exec package provides
higher-level interfaces.
If there is an error, it will be of type *PathError.
Go input arguments: (name string, argv []string, attr *ProcAttr)
Go returns: (*Process, error)
Joker input arguments: [^String name, ^arrayOfString argv, ^*ProcAttr attr]
Joker returns: [^*Process, ^Error] -
Stat
Function v1.0(Stat name)
Stat returns a FileInfo describing the named file.
If there is an error, it will be of type *PathError.
Go input arguments: (name string)
Go returns: (io/fs.FileInfo, error)
Joker input arguments: [^String name]
Joker returns: [^go.std.io.fs/FileInfo, ^Error] -
Symlink
Function v1.0(Symlink oldname newname)
Symlink creates newname as a symbolic link to oldname.
On Windows, a symlink to a non-existent oldname creates a file symlink;
if oldname is later created as a directory the symlink will not work.
If there is an error, it will be of type *LinkError.
Go input arguments: (oldname string, newname string)
Go returns: error
Joker input arguments: [^String oldname, ^String newname]
Joker returns: ^Error -
TempDir
Function v1.0(TempDir)
TempDir returns the default directory to use for temporary files.
On Unix systems, it returns $TMPDIR if non-empty, else /tmp.
On Windows, it uses GetTempPath, returning the first non-empty
value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory.
On Plan 9, it returns /tmp.
The directory is neither guaranteed to exist nor have accessible
permissions.
Go returns: string
Joker input arguments: []
Joker returns: ^String -
Truncate
Function v1.0(Truncate name size)
Truncate changes the size of the named file.
If the file is a symbolic link, it changes the size of the link's target.
If there is an error, it will be of type *PathError.
Go input arguments: (name string, size int64)
Go returns: error
Joker input arguments: [^String name, ^BigInt size]
Joker returns: ^Error -
Unsetenv
Function v1.0(Unsetenv key)
Unsetenv unsets a single environment variable.
Go input arguments: (key string)
Go returns: error
Joker input arguments: [^String key]
Joker returns: ^Error -
UserCacheDir
Function v1.0(UserCacheDir)
UserCacheDir returns the default root directory to use for user-specific
cached data. Users should create their own application-specific subdirectory
within this one and use that.
On Unix systems, it returns $XDG_CACHE_HOME as specified by
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if
non-empty, else $HOME/.cache.
On Darwin, it returns $HOME/Library/Caches.
On Windows, it returns %LocalAppData%.
On Plan 9, it returns $home/lib/cache.
If the location cannot be determined (for example, $HOME is not defined),
then it will return an error.
Go returns: (string, error)
Joker input arguments: []
Joker returns: [^String, ^Error] -
UserConfigDir
Function v1.0(UserConfigDir)
UserConfigDir returns the default root directory to use for user-specific
configuration data. Users should create their own application-specific
subdirectory within this one and use that.
On Unix systems, it returns $XDG_CONFIG_HOME as specified by
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if
non-empty, else $HOME/.config.
On Darwin, it returns $HOME/Library/Application Support.
On Windows, it returns %AppData%.
On Plan 9, it returns $home/lib.
If the location cannot be determined (for example, $HOME is not defined),
then it will return an error.
Go returns: (string, error)
Joker input arguments: []
Joker returns: [^String, ^Error] -
UserHomeDir
Function v1.0(UserHomeDir)
UserHomeDir returns the current user's home directory.
On Unix, including macOS, it returns the $HOME environment variable.
On Windows, it returns %USERPROFILE%.
On Plan 9, it returns the $home environment variable.
Go returns: (string, error)
Joker input arguments: []
Joker returns: [^String, ^Error] -
WriteFile
Function v1.0(WriteFile name data perm)
WriteFile writes data to the named file, creating it if necessary.
If the file does not exist, WriteFile creates it with permissions perm (before umask);
otherwise WriteFile truncates it before writing, without changing permissions.
Go input arguments: (name string, data []byte, perm io/fs.FileMode)
Go returns: error
Joker input arguments: [^String name, ^arrayOfByte data, ^go.std.io.fs/FileMode perm]
Joker returns: ^Error
Types
-
*File
Concrete Type v1.0File represents an open file descriptor.
-
Chdir
Receiver for *File v1.0([])
Chdir changes the current working directory to the file,
which must be a directory.
If there is an error, it will be of type *PathError.
-
Chmod
Receiver for *File v1.0([mode])
Chmod changes the mode of the file to mode.
If there is an error, it will be of type *PathError.
-
Chown
Receiver for *File v1.0([uid gid])
Chown changes the numeric uid and gid of the named file.
If there is an error, it will be of type *PathError.
On Windows, it always returns the syscall.EWINDOWS error, wrapped
in *PathError.
-
Close
Receiver for *File v1.0([])
Close closes the File, rendering it unusable for I/O.
On files that support SetDeadline, any pending I/O operations will
be canceled and return immediately with an ErrClosed error.
Close will return an error if it has already been called.
-
Fd
Receiver for *File v1.0([])
Fd returns the integer Unix file descriptor referencing the open file.
If f is closed, the file descriptor becomes invalid.
If f is garbage collected, a finalizer may close the file descriptor,
making it invalid; see runtime.SetFinalizer for more information on when
a finalizer might be run. On Unix systems this will cause the SetDeadline
methods to stop working.
Because file descriptors can be reused, the returned file descriptor may
only be closed through the Close method of f, or by its finalizer during
garbage collection. Otherwise, during garbage collection the finalizer
may close an unrelated file descriptor with the same (reused) number.
As an alternative, see the f.SyscallConn method.
-
Name
Receiver for *File v1.0([])
Name returns the name of the file as presented to Open.
-
Read
Receiver for *File v1.0([b])
Read reads up to len(b) bytes from the File and stores them in b.
It returns the number of bytes read and any error encountered.
At end of file, Read returns 0, io.EOF.
-
ReadAt
Receiver for *File v1.0([b off])
ReadAt reads len(b) bytes from the File starting at byte offset off.
It returns the number of bytes read and the error, if any.
ReadAt always returns a non-nil error when n < len(b).
At end of file, that error is io.EOF.
-
ReadDir
Receiver for *File v1.0([n])
ReadDir reads the contents of the directory associated with the file f
and returns a slice of DirEntry values in directory order.
Subsequent calls on the same file will yield later DirEntry records in the directory.
If n > 0, ReadDir returns at most n DirEntry records.
In this case, if ReadDir returns an empty slice, it will return an error explaining why.
At the end of a directory, the error is io.EOF.
If n <= 0, ReadDir returns all the DirEntry records remaining in the directory.
When it succeeds, it returns a nil error (not io.EOF).
-
ReadFrom
Receiver for *File v1.0([r])
ReadFrom implements io.ReaderFrom.
-
Readdir
Receiver for *File v1.0([n])
Readdir reads the contents of the directory associated with file and
returns a slice of up to n FileInfo values, as would be returned
by Lstat, in directory order. Subsequent calls on the same file will yield
further FileInfos.
If n > 0, Readdir returns at most n FileInfo structures. In this case, if
Readdir returns an empty slice, it will return a non-nil error
explaining why. At the end of a directory, the error is io.EOF.
If n <= 0, Readdir returns all the FileInfo from the directory in
a single slice. In this case, if Readdir succeeds (reads all
the way to the end of the directory), it returns the slice and a
nil error. If it encounters an error before the end of the
directory, Readdir returns the FileInfo read until that point
and a non-nil error.
Most clients are better served by the more efficient ReadDir method.
-
Readdirnames
Receiver for *File v1.0([n])
Readdirnames reads the contents of the directory associated with file
and returns a slice of up to n names of files in the directory,
in directory order. Subsequent calls on the same file will yield
further names.
If n > 0, Readdirnames returns at most n names. In this case, if
Readdirnames returns an empty slice, it will return a non-nil error
explaining why. At the end of a directory, the error is io.EOF.
If n <= 0, Readdirnames returns all the names from the directory in
a single slice. In this case, if Readdirnames succeeds (reads all
the way to the end of the directory), it returns the slice and a
nil error. If it encounters an error before the end of the
directory, Readdirnames returns the names read until that point and
a non-nil error.
-
Seek
Receiver for *File v1.0([offset whence])
Seek sets the offset for the next Read or Write on file to offset, interpreted
according to whence: 0 means relative to the origin of the file, 1 means
relative to the current offset, and 2 means relative to the end.
It returns the new offset and an error, if any.
The behavior of Seek on a file opened with O_APPEND is not specified.
If f is a directory, the behavior of Seek varies by operating
system; you can seek to the beginning of the directory on Unix-like
operating systems, but not on Windows.
-
SetDeadline
Receiver for *File v1.0([t])
SetDeadline sets the read and write deadlines for a File.
It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
Only some kinds of files support setting a deadline. Calls to SetDeadline
for files that do not support deadlines will return ErrNoDeadline.
On most systems ordinary files do not support deadlines, but pipes do.
A deadline is an absolute time after which I/O operations fail with an
error instead of blocking. The deadline applies to all future and pending
I/O, not just the immediately following call to Read or Write.
After a deadline has been exceeded, the connection can be refreshed
by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O
methods will return an error that wraps ErrDeadlineExceeded.
This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
That error implements the Timeout method, and calling the Timeout
method will return true, but there are other possible errors for which
the Timeout will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending
the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
-
SetReadDeadline
Receiver for *File v1.0([t])
SetReadDeadline sets the deadline for future Read calls and any
currently-blocked Read call.
A zero value for t means Read will not time out.
Not all files support setting deadlines; see SetDeadline.
-
SetWriteDeadline
Receiver for *File v1.0([t])
SetWriteDeadline sets the deadline for any future Write calls and any
currently-blocked Write call.
Even if Write times out, it may return n > 0, indicating that
some of the data was successfully written.
A zero value for t means Write will not time out.
Not all files support setting deadlines; see SetDeadline.
-
Stat
Receiver for *File v1.0([])
Stat returns the FileInfo structure describing file.
If there is an error, it will be of type *PathError.
-
Sync
Receiver for *File v1.0([])
Sync commits the current contents of the file to stable storage.
Typically, this means flushing the file system's in-memory copy
of recently written data to disk.
-
SyscallConn
Receiver for *File v1.0([])
SyscallConn returns a raw file.
This implements the syscall.Conn interface.
-
Truncate
Receiver for *File v1.0([size])
Truncate changes the size of the file.
It does not change the I/O offset.
If there is an error, it will be of type *PathError.
-
Write
Receiver for *File v1.0([b])
Write writes len(b) bytes from b to the File.
It returns the number of bytes written and an error, if any.
Write returns a non-nil error when n != len(b).
-
WriteAt
Receiver for *File v1.0([b off])
WriteAt writes len(b) bytes to the File starting at byte offset off.
It returns the number of bytes written and an error, if any.
WriteAt returns a non-nil error when n != len(b).
If file was opened with the O_APPEND flag, WriteAt returns an error.
-
WriteString
Receiver for *File v1.0([s])
WriteString is like Write, but writes the contents of string s rather than
a slice of bytes.
-
*LinkError
Concrete Type v1.0LinkError records an error during a link or symlink or rename
system call and the paths that caused it.
-
Error
Receiver for *LinkError v1.0([])
-
Unwrap
Receiver for *LinkError v1.0([])
-
*ProcAttr
Concrete Type v1.0ProcAttr holds the attributes that will be applied to a new process
started by StartProcess.
-
*Process
Concrete Type v1.0Process stores the information about a process created by StartProcess.
-
Kill
Receiver for *Process v1.0([])
Kill causes the Process to exit immediately. Kill does not wait until
the Process has actually exited. This only kills the Process itself,
not any other processes it may have started.
-
Release
Receiver for *Process v1.0([])
Release releases any resources associated with the Process p,
rendering it unusable in the future.
Release only needs to be called if Wait is not.
-
Signal
Receiver for *Process v1.0([sig])
Signal sends a signal to the Process.
Sending Interrupt on Windows is not implemented.
-
Wait
Receiver for *Process v1.0([])
Wait waits for the Process to exit, and then returns a
ProcessState describing its status and an error, if any.
Wait releases any resources associated with the Process.
On most operating systems, the Process must be a child
of the current process or an error will be returned.
-
*ProcessState
Concrete Type v1.0ProcessState stores information about a process, as reported by Wait.
-
ExitCode
Receiver for *ProcessState v1.0([])
ExitCode returns the exit code of the exited process, or -1
if the process hasn't exited or was terminated by a signal.
-
Exited
Receiver for *ProcessState v1.0([])
Exited reports whether the program has exited.
On Unix systems this reports true if the program exited due to calling exit,
but false if the program terminated due to a signal.
-
Pid
Receiver for *ProcessState v1.0([])
Pid returns the process id of the exited process.
-
String
Receiver for *ProcessState v1.0([])
-
Success
Receiver for *ProcessState v1.0([])
Success reports whether the program exited successfully,
such as with exit status 0 on Unix.
-
Sys
Receiver for *ProcessState v1.0([])
Sys returns system-dependent exit information about
the process. Convert it to the appropriate underlying
type, such as syscall.WaitStatus on Unix, to access its contents.
-
SysUsage
Receiver for *ProcessState v1.0([])
SysUsage returns system-dependent resource usage information about
the exited process. Convert it to the appropriate underlying
type, such as *syscall.Rusage on Unix, to access its contents.
(On Unix, *syscall.Rusage matches struct rusage as defined in the
getrusage(2) manual page.)
-
SystemTime
Receiver for *ProcessState v1.0([])
SystemTime returns the system CPU time of the exited process and its children.
-
UserTime
Receiver for *ProcessState v1.0([])
UserTime returns the user CPU time of the exited process and its children.
-
*SyscallError
Concrete Type v1.0SyscallError records an error from a specific system call.
-
Error
Receiver for *SyscallError v1.0([])
-
Timeout
Receiver for *SyscallError v1.0([])
Timeout reports whether this error represents a timeout.
-
Unwrap
Receiver for *SyscallError v1.0([])
-
File
Concrete Type v1.0File represents an open file descriptor.
-
LinkError
Concrete Type v1.0LinkError records an error during a link or symlink or rename
system call and the paths that caused it.
-
ProcAttr
Concrete Type v1.0ProcAttr holds the attributes that will be applied to a new process
started by StartProcess.
-
Process
Concrete Type v1.0Process stores the information about a process created by StartProcess.
-
ProcessState
Concrete Type v1.0ProcessState stores information about a process, as reported by Wait.
-
Signal
Abstract Type v1.0A Signal represents an operating system signal.
The usual underlying implementation is operating system-dependent:
on Unix it is syscall.Signal.
-
Signal
Method for Signal v1.0([])
-
String
Method for Signal v1.0([])
-
SyscallError
Concrete Type v1.0SyscallError records an error from a specific system call.
-
arrayOfFile
Concrete Type v1.0File represents an open file descriptor.
-
arrayOfLinkError
Concrete Type v1.0LinkError records an error during a link or symlink or rename
system call and the paths that caused it.
-
arrayOfProcAttr
Concrete Type v1.0ProcAttr holds the attributes that will be applied to a new process
started by StartProcess.
-
arrayOfProcess
Concrete Type v1.0Process stores the information about a process created by StartProcess.
-
arrayOfProcessState
Concrete Type v1.0ProcessState stores information about a process, as reported by Wait.
-
arrayOfSignal
Concrete Type v1.0A Signal represents an operating system signal.
The usual underlying implementation is operating system-dependent:
on Unix it is syscall.Signal.
-
arrayOfSyscallError
Concrete Type v1.0SyscallError records an error from a specific system call.