package os

Import Path
	os (on golang.org and go.dev)

Dependency Relation
	imports 13 packages, and imported by 47 packages

Involved Source Files
	    dir.go
	    dir_unix.go
	    env.go
	    error.go
	    error_errno.go
	    error_posix.go
	    exec.go
	    exec_posix.go
	    exec_unix.go
	    executable.go
	    executable_procfs.go
	d-> file.go
	    file_posix.go
	    file_unix.go
	    getwd.go
	    path.go
	    path_unix.go
	    pipe_linux.go
	    proc.go
	    rawconn.go
	    readfrom_linux.go
	    removeall_at.go
	    stat.go
	    stat_linux.go
	    stat_unix.go
	    sticky_notbsd.go
	    str.go
	    sys.go
	    sys_linux.go
	    sys_unix.go
	    types.go
	    types_unix.go
	    wait_waitid.go

Exported Type Names

type File (struct) File represents an open file descriptor. (*T) Chdir() error (*T) Chmod(mode FileMode) error (*T) Chown(uid, gid int) error (*T) Close() error (*T) Fd() uintptr (*T) Name() string (*T) Read(b []byte) (n int, err error) (*T) ReadAt(b []byte, off int64) (n int, err error) (*T) ReadFrom(r io.Reader) (n int64, err error) (*T) Readdir(n int) ([]FileInfo, error) (*T) Readdirnames(n int) (names []string, err error) (*T) Seek(offset int64, whence int) (ret int64, err error) (*T) SetDeadline(t time.Time) error (*T) SetReadDeadline(t time.Time) error (*T) SetWriteDeadline(t time.Time) error (*T) Stat() (FileInfo, error) (*T) Sync() error (*T) SyscallConn() (syscall.RawConn, error) (*T) Truncate(size int64) error (*T) Write(b []byte) (n int, err error) (*T) WriteAt(b []byte, off int64) (n int, err error) (*T) WriteString(s string) (n int, err error) *T : io.Closer *T : io.ReadCloser *T : io.Reader *T : io.ReaderAt *T : io.ReaderFrom *T : io.ReadSeeker *T : io.ReadWriteCloser *T : io.ReadWriter *T : io.ReadWriteSeeker *T : io.Seeker *T : io.StringWriter *T : io.WriteCloser *T : io.Writer *T : io.WriterAt *T : io.WriteSeeker *T : mime/multipart.File *T : net/http.File *T : syscall.Conn func Create(name string) (*File, error) func NewFile(fd uintptr, name string) *File func Open(name string) (*File, error) func OpenFile(name string, flag int, perm FileMode) (*File, error) func Pipe() (r *File, w *File, err error) func Pipe() (r *File, w *File, err error) func io/ioutil.TempFile(dir, pattern string) (f *File, err error) func net.(*TCPListener).File() (f *File, err error) func net.(*UnixListener).File() (f *File, err error) func net.FileConn(f *File) (c net.Conn, err error) func net.FileListener(f *File) (ln net.Listener, err error) func net.FilePacketConn(f *File) (c net.PacketConn, err error) var Stderr *File var Stdin *File var Stdout *File
type FileInfo (interface) A FileInfo describes a file and is returned by Stat and Lstat. (T) IsDir() bool (T) ModTime() time.Time (T) Mode() FileMode (T) Name() string (T) Size() int64 (T) Sys() interface{} func Lstat(name string) (FileInfo, error) func Stat(name string) (FileInfo, error) func (*File).Readdir(n int) ([]FileInfo, error) func (*File).Stat() (FileInfo, error) func archive/tar.(*Header).FileInfo() FileInfo func archive/zip.(*FileHeader).FileInfo() FileInfo func io/ioutil.ReadDir(dirname string) ([]FileInfo, error) func net/http.File.Readdir(count int) ([]FileInfo, error) func net/http.File.Stat() (FileInfo, error) func SameFile(fi1, fi2 FileInfo) bool func archive/tar.FileInfoHeader(fi FileInfo, link string) (*tar.Header, error) func archive/zip.FileInfoHeader(fi FileInfo) (*zip.FileHeader, error)
type FileMode uint32 A FileMode represents a file's mode and permission bits. The bits have the same definition on all systems, so that information about files can be moved from one system to another portably. Not all bits apply to all systems. The only required bit is ModeDir for directories. (T) IsDir() bool (T) IsRegular() bool (T) Perm() FileMode (T) String() string T : expvar.Var T : fmt.Stringer func FileInfo.Mode() FileMode func FileMode.Perm() FileMode func archive/zip.(*FileHeader).Mode() (mode FileMode) func Chmod(name string, mode FileMode) error func Mkdir(name string, perm FileMode) error func MkdirAll(path string, perm FileMode) error func OpenFile(name string, flag int, perm FileMode) (*File, error) func (*File).Chmod(mode FileMode) error func archive/zip.(*FileHeader).SetMode(mode FileMode) func io/ioutil.WriteFile(filename string, data []byte, perm FileMode) error const ModeAppend const ModeCharDevice const ModeDevice const ModeDir const ModeExclusive const ModeIrregular const ModeNamedPipe const ModePerm const ModeSetgid const ModeSetuid const ModeSocket const ModeSticky const ModeSymlink const ModeTemporary const ModeType
type LinkError (struct) LinkError records an error during a link or symlink or rename system call and the paths that caused it. Err error New string Old string Op string (*T) Error() string (*T) Unwrap() error *T : error
type PathError (struct) PathError records an error and the operation and file path that caused it. Err error Op string Path string (*T) Error() string (*T) Timeout() bool (*T) Unwrap() error *T : error
type ProcAttr (struct) ProcAttr holds the attributes that will be applied to a new process started by StartProcess. Dir string Env []string Files []*File Sys *syscall.SysProcAttr func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error)
type Process (struct) Process stores the information about a process created by StartProcess. Pid int (*T) Kill() error (*T) Release() error (*T) Signal(sig Signal) error (*T) Wait() (*ProcessState, error) func FindProcess(pid int) (*Process, error) func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error)
type ProcessState (struct) ProcessState stores information about a process, as reported by Wait. (*T) ExitCode() int (*T) Exited() bool (*T) Pid() int (*T) String() string (*T) Success() bool (*T) Sys() interface{} (*T) SysUsage() interface{} (*T) SystemTime() time.Duration (*T) UserTime() time.Duration *T : expvar.Var *T : fmt.Stringer func (*Process).Wait() (*ProcessState, error)
type Signal (interface) A Signal represents an operating system signal. The usual underlying implementation is operating system-dependent: on Unix it is syscall.Signal. (T) Signal() (T) String() string syscall.Signal T : expvar.Var T : fmt.Stringer func (*Process).Signal(sig Signal) error func os/signal.Ignore(sig ...Signal) func os/signal.Ignored(sig Signal) bool func os/signal.Notify(c chan<- Signal, sig ...Signal) func os/signal.Notify(c chan<- Signal, sig ...Signal) func os/signal.Reset(sig ...Signal) func os/signal.Stop(c chan<- Signal) var Interrupt var Kill
type SyscallError (struct) SyscallError records an error from a specific system call. Err error Syscall string (*T) Error() string (*T) Timeout() bool (*T) Unwrap() error *T : error
Exported Values
var Args []string Args hold the command-line arguments, starting with the program name.
func Chdir(dir string) error Chdir changes the current working directory to the named directory. If there is an error, it will be of type *PathError.
func Chmod(name string, mode FileMode) error 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.
func Chown(name string, uid, gid int) error 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.
func Chtimes(name string, atime time.Time, mtime time.Time) error 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.
func Clearenv() Clearenv deletes all environment variables.
func Create(name string) (*File, error) 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.
const DevNull = "/dev/null" DevNull is the name of the operating system's ``null device.'' On Unix-like systems, it is "/dev/null"; on Windows, "NUL".
func Environ() []string Environ returns a copy of strings representing the environment, in the form "key=value".
var ErrClosed error // "file already closed" Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with errors.Is.
var ErrDeadlineExceeded error // "i/o timeout" Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with errors.Is.
var ErrExist error // "file already exists" Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with errors.Is.
var ErrInvalid error // "invalid argument" ErrInvalid indicates an invalid argument. Methods on File will return this error when the receiver is nil.
var ErrNoDeadline error // "file type does not support deadline" Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with errors.Is.
var ErrNotExist error // "file does not exist" Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with errors.Is.
var ErrPermission error // "permission denied" Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with errors.Is.
func Executable() (string, error) 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.
func Exit(code int) 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].
func Expand(s string, mapping func(string) string) string Expand replaces ${var} or $var in the string based on the mapping function. For example, os.ExpandEnv(s) is equivalent to os.Expand(s, os.Getenv).
func ExpandEnv(s string) string 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.
func FindProcess(pid int) (*Process, error) 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.
func Getegid() int Getegid returns the numeric effective group id of the caller. On Windows, it returns -1.
func Getenv(key string) string 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.
func Geteuid() int Geteuid returns the numeric effective user id of the caller. On Windows, it returns -1.
func Getgid() int Getgid returns the numeric group id of the caller. On Windows, it returns -1.
func Getgroups() ([]int, error) 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.
func Getpagesize() int Getpagesize returns the underlying system's memory page size.
func Getpid() int Getpid returns the process id of the caller.
func Getppid() int Getppid returns the process id of the caller's parent.
func Getuid() int Getuid returns the numeric user id of the caller. On Windows, it returns -1.
func Getwd() (dir string, err error) 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.
func Hostname() (name string, err error) Hostname returns the host name reported by the kernel.
var Interrupt Signal The 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.
func IsExist(err error) bool 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.
func IsNotExist(err error) bool 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.
func IsPathSeparator(c uint8) bool IsPathSeparator reports whether c is a directory separator character.
func IsPermission(err error) bool 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.
func IsTimeout(err error) bool IsTimeout returns a boolean indicating whether the error is known to report that a timeout occurred.
var Kill Signal The 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.
func Lchown(name string, uid, gid int) error 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.
func LookupEnv(key string) (string, bool) 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.
func Lstat(name string) (FileInfo, error) 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.
func Mkdir(name string, perm FileMode) error 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.
func MkdirAll(path string, perm FileMode) error 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.
const ModeAppend FileMode = 1073741824 // a: append-only The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeCharDevice FileMode = 2097152 // c: Unix character device, when ModeDevice is set The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeDevice FileMode = 67108864 // D: device file The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeDir FileMode = 2147483648 // d: is a directory The single letters are the abbreviations used by the String method's formatting.
const ModeExclusive FileMode = 536870912 // l: exclusive use The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeIrregular FileMode = 524288 // ?: non-regular file; nothing else is known about this file The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeNamedPipe FileMode = 33554432 // p: named pipe (FIFO) The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModePerm FileMode = 511 // Unix permission bits The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeSetgid FileMode = 4194304 // g: setgid The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeSetuid FileMode = 8388608 // u: setuid The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeSocket FileMode = 16777216 // S: Unix domain socket The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeSticky FileMode = 1048576 // t: sticky The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeTemporary FileMode = 268435456 // T: temporary file; Plan 9 only The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.
const ModeType FileMode = 2401763328 Mask for the type bits. For regular files, none will be set.
func NewFile(fd uintptr, name string) *File 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).
func NewSyscallError(syscall string, err error) error 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.
const O_APPEND int = 1024 // append data to the file when writing. The remaining values may be or'ed in to control behavior.
const O_CREATE int = 64 // create a new file if none exists. Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
const O_EXCL int = 128 // used with O_CREATE, file must not exist. Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
const O_RDONLY int = 0 // open the file read-only. Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified.
const O_RDWR int = 2 // open the file read-write. Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
const O_SYNC int = 1052672 // open for synchronous I/O. Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
const O_TRUNC int = 512 // truncate regular writable file when opened. Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
const O_WRONLY int = 1 // open the file write-only. Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
func Open(name string) (*File, error) 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.
func OpenFile(name string, flag int, perm FileMode) (*File, error) 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.
const PathListSeparator = 58 // OS-specific path list separator
const PathSeparator = 47 // OS-specific path separator
func Pipe() (r *File, w *File, err error) Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any.
func Remove(name string) error Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func RemoveAll(path string) error 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.
func Rename(oldpath, newpath string) error 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.
func SameFile(fi1, fi2 FileInfo) bool 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.
const SEEK_CUR int = 1 // seek relative to the current offset Seek whence values. Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.
const SEEK_END int = 2 // seek relative to the end Seek whence values. Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.
const SEEK_SET int = 0 // seek relative to the origin of the file Seek whence values. Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.
func Setenv(key, value string) error Setenv sets the value of the environment variable named by the key. It returns an error, if any.
func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error) 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.
func Stat(name string) (FileInfo, error) Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError.
var Stderr *File Stdin, 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.
var Stdin *File Stdin, 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.
var Stdout *File Stdin, 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.
func TempDir() string 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.
func Truncate(name string, size int64) error 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.
func Unsetenv(key string) error Unsetenv unsets a single environment variable.
func UserCacheDir() (string, error) 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.
func UserConfigDir() (string, error) 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.
func UserHomeDir() (string, error) 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.