args
pub fn args() []stringPurpose
sys_args is the private builtin spelling. Calling args from this module would resolve to the public wrapper below and recurse.
Parameters
none
Returns
[]string — slice result
API
#osProcess, files, environment. Hosted File: open/create/read/write/close. getwd returns empty on failure.
argspub fn args() []stringsys_args is the private builtin spelling. Calling args from this module would resolve to the public wrapper below and recurse.
none
[]string — slice result
argvpub fn argv() []stringargv is retained as the compatibility spelling used by older Xu programs.
none
[]string — slice result
readpub fn read(path string) stringread reads the file named by path and returns the contents. Throws on failure.
path stringstring — result string
writepub fn write(path string, data string) intwrite writes data to the named file, creating it if necessary. Throws on failure.
path stringdata stringint — bytes written
struct Filepub struct File {
}Streaming file owner. Non-Copy via its compiler-managed drop hook.
none
const o_rdonlypub const o_rdonly = 0Public constant `o_rdonly`. Value `0`.
none
const o_createpub const o_create = 1Public constant `o_create`. Value `1`.
none
const o_appendpub const o_append = 2Public constant `o_append`. Value `2`.
none
const o_exclpub const o_excl = 3Public constant `o_excl`. Value `3`.
none
const o_lockpub const o_lock = 4Public constant `o_lock`. Value `4`.
none
const o_lock_existingpub const o_lock_existing = 5Public constant `o_lock_existing`. Value `5`.
none
open_lockpub fn open_lock(path string, existing bool) FileExclusive nonblocking process lock. Closing File or process termination releases it. The stable lock file must never be unlinked while in use. o_lock creates without truncating; o_lock_existing opens read-only. Throws on failure.
path stringexisting boolFile — a value of this type
openpub fn open(path string) FileOpen. Throws on failure.
path stringFile — a value of this type
createpub fn create(path string) FileCreate. Throws on failure.
path stringFile — a value of this type
open_appendpub fn open_append(path string) FileOpen append. Throws on failure.
path stringFile — a value of this type
create_exclpub fn create_excl(path string) FileCreate excl. Throws on failure.
path stringFile — a value of this type
(&File) readpub fn (f &File) read(max int) stringMethod on `&File`: read up to max bytes. Throws on failure.
f &Filemax intstring — result string
(&File) writepub fn (f &File) write(data string) intMethod on `&File`: write data and return the byte count. Throws on failure.
f &Filedata stringint — bytes written
(&mut File) closepub fn (f &mut File) close() intMethod on `&mut File`: close the resource. Throws on failure.
f &mut Fileint — a value of this type
const seek_setpub const seek_set = 0Public constant `seek_set`. Value `0`.
none
const seek_curpub const seek_cur = 1Public constant `seek_cur`. Value `1`.
none
const seek_endpub const seek_end = 2Public constant `seek_end`. Value `2`.
none
(&File) seekpub fn (f &File) seek(offset int, whence int) intMethod on `&File`: move the read position. whence 0/1/2 = absolute / relative / from end. Throws on failure.
f &Fileoffset intwhence intint — a value of this type
struct Pipepub struct Pipe {
pub r File
pub w File
}Public struct `Pipe`.
r Filew Filepipepub fn pipe() Pipepipe; returns Pipe. Throws on failure.
none
Pipe — a value of this type
read_dirpub fn read_dir(path string) stringsys_read_dir avoids the same-name wrapper shadowing the private builtin. Throws on failure.
path stringstring — result string
listdirpub fn listdir(path string) stringlistdir is retained as a compatibility spelling. Throws on failure.
path stringstring — result string
getpidpub fn getpid() int===== System information =====
none
int — a value of this type
getppidpub fn getppid() intgetppid; returns int.
none
int — a value of this type
getuidpub fn getuid() intgetuid; returns int.
none
int — a value of this type
getgidpub fn getgid() intgetgid; returns int.
none
int — a value of this type
geteuidpub fn geteuid() intgeteuid; returns int.
none
int — a value of this type
getegidpub fn getegid() intgetegid; returns int.
none
int — a value of this type
getpagesizepub fn getpagesize() intgetpagesize; returns int.
none
int — a value of this type
hostnamepub fn hostname() stringhostname; returns string.
none
string — result string
getwdpub fn getwd() stringgetwd returns a rooted path name corresponding to the current directory.
none
string — result string
getenvpub fn getenv(name string) stringgetenv retrieves the value of the environment variable named by the key.
name stringstring — result string
struct EnvValpub struct EnvVal {
pub value string
pub found bool
}EnvVal is os.LookupEnv's two results: found is false when unset (empty value with found true is a defined empty string).
value stringfound boollookup_envpub fn lookup_env(name string) EnvValLookup env.
name stringEnvVal — a value of this type
environpub fn environ() []stringenviron; returns []string.
none
[]string — slice result
temp_dirpub fn temp_dir() stringTemp directory.
none
string — result string
home_dirpub fn home_dir() stringHome directory.
none
string — result string
user_home_dirpub fn user_home_dir() stringUser home directory. Throws on failure.
none
string — result string
path_separatorpub fn path_separator() intPath separator.
none
int — a value of this type
is_path_separatorpub fn is_path_separator(c int) boolWhether it is path separator.
c intbool — true or false
path_list_separatorpub fn path_list_separator() intpath_list_separator is os.PathListSeparator: ';' on Windows, ':' elsewhere.
none
int — a value of this type
dev_nullpub fn dev_null() stringdev_null is os.DevNull: "NUL" on Windows, "/dev/null" elsewhere.
none
string — result string
user_cache_dirpub fn user_cache_dir() stringUser cache directory. Throws on failure.
none
string — result string
user_config_dirpub fn user_config_dir() stringUser config directory. Throws on failure.
none
string — result string
statpub fn stat(path string) FileInfo===== Filesystem ops ===== Throws on failure.
path stringFileInfo — a value of this type
mkdirpub fn mkdir(path string) intCreate a directory. Throws on failure.
path stringint — a value of this type
renamepub fn rename(old string, new string) intRename. Throws on failure.
old stringnew stringint — a value of this type
removepub fn remove(path string) intRemove. Throws on failure.
path stringint — a value of this type
chmodpub fn chmod(path string, mode int) intchmod; returns int. Throws on failure.
path stringmode intint — a value of this type
chdirpub fn chdir(path string) intchdir; returns int. Throws on failure.
path stringint — a value of this type
symlinkpub fn symlink(oldpath string, newpath string) intsymlink; returns int. Throws on failure.
oldpath stringnewpath stringint — a value of this type
readlinkpub fn readlink(path string) stringreadlink; returns string. Throws on failure.
path stringstring — result string
is_dirpub fn is_dir(path string) boolWhether it is a directory.
path stringbool — true or false
is_not_existpub fn is_not_exist(msg string) boolWhether it is not exist.
msg stringbool — true or false
is_existpub fn is_exist(msg string) boolWhether it is exist.
msg stringbool — true or false
is_permissionpub fn is_permission(msg string) boolWhether it is permission.
msg stringbool — true or false
is_timeoutpub fn is_timeout(msg string) boolWhether it is timeout.
msg stringbool — true or false
struct DirEntrypub struct DirEntry {
pub name string
pub is_dir bool
}Public struct `DirEntry`.
name stringis_dir boolentriespub fn entries(path0 string) []DirEntryentries; returns []DirEntry. Throws on failure.
path0 string[]DirEntry — slice result
mkdir_allpub fn mkdir_all(path0 string) intMkdir all. Throws on failure.
path0 stringint — a value of this type
mkdir_temppub fn mkdir_temp(dir string, pattern string) stringMkdir temp. Throws on failure.
dir stringpattern stringstring — result string
create_temppub fn create_temp(dir string, pattern string) stringCreate temp. Throws on failure.
dir stringpattern stringstring — result string
remove_allpub fn remove_all(path0 string) intRemove all.
path0 stringint — a value of this type
expand_envpub fn expand_env(s &string) stringExpand env.
s &stringstring — result string
closed_filepub fn closed_file() FileA closed owner for aggregate initialization; no resource is acquired.
none
File — a value of this type
(&mut File) takepub fn (f &mut File) take() FileTransfer a field-owned File without cloning or moving through a borrow. Throws on failure.
f &mut FileFile — a value of this type
(&mut File) release_descriptorpub fn (f &mut File) release_descriptor() intExplicit ownership handoff to a raw platform adapter. The adapter must release the returned descriptor exactly once; this owner becomes closed. Throws on failure.
f &mut Fileint — a value of this type
(&File) descriptorpub fn (f &File) descriptor() intBorrowed raw descriptor for platform adapters. It does not transfer ownership callers must not close it or manufacture another owner from it. Throws on failure.
f &Fileint — a value of this type
struct DirFSpub struct DirFS {
pub dir string
}`os.DirFS`: a rooted tree that implements the io/fs.FS method set (Open / Stat / ReadFile / ReadDir / Sub). os imports io/fs; DirFS is `fs.FS` via interfaces. Xu: no interface values, so this concrete type lives here; io/fs helpers take `&os.DirFS`. This package does not import io/fs (no cycle).
dir stringdir_fspub fn dir_fs(dir string) DirFSDirectory fs.
dir stringDirFS — a value of this type
(&DirFS) openpub fn (d &DirFS) open(name string) FileMethod on `&DirFS`: open. Throws on failure.
d &DirFSname stringFile — a value of this type
(&DirFS) statpub fn (d &DirFS) stat(name string) FileInfoMethod on `&DirFS`: read metadata. Throws on failure.
d &DirFSname stringFileInfo — a value of this type
(&DirFS) read_dirpub fn (d &DirFS) read_dir(name string) []DirEntryMethod on `&DirFS`: read directory. Throws on failure.
d &DirFSname string[]DirEntry — slice result
(&DirFS) read_filepub fn (d &DirFS) read_file(name string) stringMethod on `&DirFS`: read file. Throws on failure.
d &DirFSname stringstring — result string
(&DirFS) subpub fn (d &DirFS) sub(name string) DirFSMethod on `&DirFS`: subtract. Throws on failure.
d &DirFSname stringDirFS — a value of this type
(&File) read_resultpub fn (f &File) read_result(n int) io.ReadResultMethod on `&File`: read result.
f &Filen intio.ReadResult — a value of this type
(&File) write_resultpub fn (f &File) write_result(data string) io.WriteResultMethod on `&File`: write result.
f &Filedata stringio.WriteResult — a value of this type
socketpub fn socket(domain int, typ int, proto int) intsocket; returns int. Throws on failure.
domain inttyp intproto intint — a value of this type
bind4pub fn bind4(fd int, a int, b int, c int, d int, port int) intbind4; returns int. Throws on failure.
fd inta intb intc intd intport intint — a value of this type
connect4pub fn connect4(fd int, a int, b int, c int, d int, port int) intconnect4; returns int. Throws on failure.
fd inta intb intc intd intport intint — a value of this type
bind6pub fn bind6(fd int, ip string, port int) intIPv6 socket address helpers. `ip` is the 16-byte raw IPv6 value used by net.IP; the runtime validates its length before touching the host socket. Throws on failure.
fd intip stringport intint — a value of this type
connect6pub fn connect6(fd int, ip string, port int) intconnect6; returns int. Throws on failure.
fd intip stringport intint — a value of this type
bind_unixpub fn bind_unix(fd int, path string) intUnix-domain pathname sockets. These calls are available on Darwin/Linux the hosted runtime returns an explicit unsupported error on Windows. Throws on failure.
fd intpath stringint — a value of this type
connect_unixpub fn connect_unix(fd int, path string) intConnect unix. Throws on failure.
fd intpath stringint — a value of this type
listenpub fn listen(fd int, backlog int) intListen for connections. Throws on failure.
fd intbacklog intint — a value of this type
acceptpub fn accept(fd int) intAccept one connection. Throws on failure.
fd intint — a value of this type
sendtopub fn sendto(fd int, addr string, data string) intsendto; returns int. Throws on failure.
fd intaddr stringdata stringint — a value of this type
recvfrompub fn recvfrom(fd int, max int) stringrecvfrom; returns string. Throws on failure.
fd intmax intstring — result string
fd_readpub fn fd_read(fd int, max int) stringFd read. Throws on failure.
fd intmax intstring — result string
fd_writepub fn fd_write(fd int, data string) intFd write. Throws on failure.
fd intdata stringint — a value of this type
fd_closepub fn fd_close(fd int) intFd close. Throws on failure.
fd intint — a value of this type
socket_readpub fn socket_read(fd int, max int) stringSocket-specific I/O. Generic fd_* maps to file handles on Windows Winsock SOCKETs must instead use recv/send/closesocket. Keep these wrappers private to the net package's higher-level Conn/PacketConn paths. Throws on failure.
fd intmax intstring — result string
socket_writepub fn socket_write(fd int, data string) intSocket write. Throws on failure.
fd intdata stringint — a value of this type
socket_closepub fn socket_close(fd int) intSocket close. Throws on failure.
fd intint — a value of this type
set_sock_timeoutpub fn set_sock_timeout(fd int, ns int) intset_sock_timeout sets SO_SNDTIMEO and SO_RCVTIMEO. ns is relative 0 clears. connect honors it on Darwin; Linux connect still uses SYN retries. read/write honor it on both. Throws on failure.
fd intns intint — a value of this type
interface_datapub fn interface_data(name string) stringinterface_data returns the host network-interface snapshot used by the net package. Passing an empty name returns NUL-separated interface names passing a name returns a fixed binary metadata record. Platform ABI structs stay behind this os/runtime boundary. Throws on failure.
name stringstring — result string
(&File) read_npub fn (f &File) read_n(n int) stringio.StreamReader/StreamWriter adapters. These use the existing descriptor callers retain responsibility for close and may continue using File APIs. Throws on failure.
f &Filen intstring — result string
(&File) write_strpub fn (f &File) write_str(data string) intMethod on `&File`: write a string. Throws on failure.
f &Filedata stringint — a value of this type