args
pub fn args() []string用途
args,返回 []string。
参数
无
返回
[]string — 切片结果
API
#os进程、文件、环境。hosted 下 File:open/create/read/write/close。getwd 失败返空串。
argspub fn args() []stringargs,返回 []string。
无
[]string — 切片结果
argvpub fn argv() []string命令行参数。
无
[]string — 切片结果
readpub fn read(path string) string读出最多 max 字节。失败时 throw。
path stringstring — 结果字符串
writepub fn write(path string, data string) int写入数据,返回写入的字节数。失败时 throw。
path stringdata stringint — 写入的字节数
struct Filepub struct File {
}公开结构体 `File`。
无
const o_rdonlypub const o_rdonly = 0公开常量 `o_rdonly`。 值为 `0`
无
const o_createpub const o_create = 1公开常量 `o_create`。 值为 `1`
无
const o_appendpub const o_append = 2公开常量 `o_append`。 值为 `2`
无
const o_exclpub const o_excl = 3公开常量 `o_excl`。 值为 `3`
无
const o_lockpub const o_lock = 4公开常量 `o_lock`。 值为 `4`
无
const o_lock_existingpub const o_lock_existing = 5公开常量 `o_lock_existing`。 值为 `5`
无
open_lockpub fn open_lock(path string, existing bool) File打开加锁。失败时 throw。
path stringexisting boolFile — 该类型的值
openpub fn open(path string) File打开。失败时 throw。
path stringFile — 该类型的值
createpub fn create(path string) File创建。失败时 throw。
path stringFile — 该类型的值
open_appendpub fn open_append(path string) File打开append。失败时 throw。
path stringFile — 该类型的值
create_exclpub fn create_excl(path string) File创建excl。失败时 throw。
path stringFile — 该类型的值
(&File) readpub fn (f &File) read(max int) string`&File` 上的方法:读出最多 max 字节。失败时 throw。
f &Filemax intstring — 结果字符串
(&File) writepub fn (f &File) write(data string) int`&File` 上的方法:写入数据,返回写入的字节数。失败时 throw。
f &Filedata stringint — 写入的字节数
(&mut File) closepub fn (f &mut File) close() int`&mut File` 上的方法:关闭资源。失败时 throw。
f &mut Fileint — 该类型的值
const seek_setpub const seek_set = 0公开常量 `seek_set`。 值为 `0`
无
const seek_curpub const seek_cur = 1公开常量 `seek_cur`。 值为 `1`
无
const seek_endpub const seek_end = 2公开常量 `seek_end`。 值为 `2`
无
(&File) seekpub fn (f &File) seek(offset int, whence int) int`&File` 上的方法:按 whence 把读位置移到 offset。whence 0/1/2 分别为绝对、相对、从末尾。失败时 throw。
f &Fileoffset intwhence intint — 该类型的值
struct Pipepub struct Pipe {
pub r File
pub w File
}公开结构体 `Pipe`。
r Filew Filepipepub fn pipe() Pipepipe,返回 Pipe。失败时 throw。
无
Pipe — 该类型的值
read_dirpub fn read_dir(path string) string列目录。失败时 throw。
path stringstring — 结果字符串
listdirpub fn listdir(path string) string列出目录(文本)。失败时 throw。
path stringstring — 结果字符串
getpidpub fn getpid() int进程 id。
无
int — 该类型的值
getppidpub fn getppid() int父进程 id。
无
int — 该类型的值
getuidpub fn getuid() int用户 id。
无
int — 该类型的值
getgidpub fn getgid() int组 id。
无
int — 该类型的值
geteuidpub fn geteuid() int有效用户 id。
无
int — 该类型的值
getegidpub fn getegid() int有效组 id。
无
int — 该类型的值
getpagesizepub fn getpagesize() int页大小。
无
int — 该类型的值
hostnamepub fn hostname() string主机名。
无
string — 结果字符串
getwdpub fn getwd() string工作目录。
无
string — 结果字符串
getenvpub fn getenv(name string) string读环境变量。
name stringstring — 结果字符串
struct EnvValpub struct EnvVal {
pub value string
pub found bool
}公开结构体 `EnvVal`。
value stringfound boollookup_envpub fn lookup_env(name string) EnvVal查找env。
name stringEnvVal — 该类型的值
environpub fn environ() []string环境变量表。
无
[]string — 切片结果
temp_dirpub fn temp_dir() string临时目录。
无
string — 结果字符串
home_dirpub fn home_dir() string家目录。
无
string — 结果字符串
user_home_dirpub fn user_home_dir() string用户家目录目录部分。失败时 throw。
无
string — 结果字符串
path_separatorpub fn path_separator() int路径分隔符。
无
int — 该类型的值
is_path_separatorpub fn is_path_separator(c int) bool是否路径分隔符。
c intbool — 是否成立
path_list_separatorpub fn path_list_separator() intpathlistseparator。
无
int — 该类型的值
dev_nullpub fn dev_null() stringdevnull。
无
string — 结果字符串
user_cache_dirpub fn user_cache_dir() string用户缓存目录。失败时 throw。
无
string — 结果字符串
user_config_dirpub fn user_config_dir() string用户配置目录。失败时 throw。
无
string — 结果字符串
statpub fn stat(path string) FileInfo读取元信息。失败时 throw。
path stringFileInfo — 该类型的值
mkdirpub fn mkdir(path string) int创建目录。失败时 throw。
path stringint — 该类型的值
renamepub fn rename(old string, new string) int重命名。失败时 throw。
old stringnew stringint — 该类型的值
removepub fn remove(path string) int删除。失败时 throw。
path stringint — 该类型的值
chmodpub fn chmod(path string, mode int) int改权限。失败时 throw。
path stringmode intint — 该类型的值
chdirpub fn chdir(path string) int改目录。失败时 throw。
path stringint — 该类型的值
symlinkpub fn symlink(oldpath string, newpath string) intsymlink,返回 int。失败时 throw。
oldpath stringnewpath stringint — 该类型的值
readlinkpub fn readlink(path string) stringreadlink,返回 string。失败时 throw。
path stringstring — 结果字符串
is_dirpub fn is_dir(path string) bool是否为目录。
path stringbool — 是否成立
is_not_existpub fn is_not_exist(msg string) bool是否不存在类错误。
msg stringbool — 是否成立
is_existpub fn is_exist(msg string) bool是否已存在类错误。
msg stringbool — 是否成立
is_permissionpub fn is_permission(msg string) bool判断是否 permission。
msg stringbool — 是否成立
is_timeoutpub fn is_timeout(msg string) bool判断是否 timeout。
msg stringbool — 是否成立
struct DirEntrypub struct DirEntry {
pub name string
pub is_dir bool
}公开结构体 `DirEntry`。
name stringis_dir boolentriespub fn entries(path0 string) []DirEntry列出目录项。失败时 throw。
path0 string[]DirEntry — 切片结果
mkdir_allpub fn mkdir_all(path0 string) int递归建目录。失败时 throw。
path0 stringint — 该类型的值
mkdir_temppub fn mkdir_temp(dir string, pattern string) string建临时目录。失败时 throw。
dir stringpattern stringstring — 结果字符串
create_temppub fn create_temp(dir string, pattern string) string建临时文件。失败时 throw。
dir stringpattern stringstring — 结果字符串
remove_allpub fn remove_all(path0 string) int递归删除。
path0 stringint — 该类型的值
expand_envpub fn expand_env(s &string) string展开 $VAR。
s &stringstring — 结果字符串
closed_filepub fn closed_file() Fileclosed文件。
无
File — 该类型的值
(&mut File) takepub fn (f &mut File) take() File在 `&mut File` 上调用 `take`。失败时 throw。
f &mut FileFile — 该类型的值
(&mut File) release_descriptorpub fn (f &mut File) release_descriptor() int`&mut File` 上的方法:releasedescriptor。失败时 throw。
f &mut Fileint — 该类型的值
(&File) descriptorpub fn (f &File) descriptor() int在 `&File` 上调用 `descriptor`。失败时 throw。
f &Fileint — 该类型的值
struct DirFSpub struct DirFS {
pub dir string
}公开结构体 `DirFS`。
dir stringdir_fspub fn dir_fs(dir string) DirFS目录文件系统。
dir stringDirFS — 该类型的值
(&DirFS) openpub fn (d &DirFS) open(name string) File`&DirFS` 上的方法:打开。失败时 throw。
d &DirFSname stringFile — 该类型的值
(&DirFS) statpub fn (d &DirFS) stat(name string) FileInfo`&DirFS` 上的方法:读取元信息。失败时 throw。
d &DirFSname stringFileInfo — 该类型的值
(&DirFS) read_dirpub fn (d &DirFS) read_dir(name string) []DirEntry`&DirFS` 上的方法:列目录。失败时 throw。
d &DirFSname string[]DirEntry — 切片结果
(&DirFS) read_filepub fn (d &DirFS) read_file(name string) string`&DirFS` 上的方法:读文件。失败时 throw。
d &DirFSname stringstring — 结果字符串
(&DirFS) subpub fn (d &DirFS) sub(name string) DirFS`&DirFS` 上的方法:相减。失败时 throw。
d &DirFSname stringDirFS — 该类型的值
(&File) read_resultpub fn (f &File) read_result(n int) io.ReadResult`&File` 上的方法:读取结果。
f &Filen intio.ReadResult — 该类型的值
(&File) write_resultpub fn (f &File) write_result(data string) io.WriteResult`&File` 上的方法:写入结果。
f &Filedata stringio.WriteResult — 该类型的值
socketpub fn socket(domain int, typ int, proto int) int套接字。失败时 throw。
domain inttyp intproto intint — 该类型的值
bind4pub fn bind4(fd int, a int, b int, c int, d int, port int) intIPv4 bind。失败时 throw。
fd inta intb intc intd intport intint — 该类型的值
connect4pub fn connect4(fd int, a int, b int, c int, d int, port int) intIPv4 connect。失败时 throw。
fd inta intb intc intd intport intint — 该类型的值
bind6pub fn bind6(fd int, ip string, port int) intbind6,返回 int。失败时 throw。
fd intip stringport intint — 该类型的值
connect6pub fn connect6(fd int, ip string, port int) intconnect6,返回 int。失败时 throw。
fd intip stringport intint — 该类型的值
bind_unixpub fn bind_unix(fd int, path string) intbindUnix 时间。失败时 throw。
fd intpath stringint — 该类型的值
connect_unixpub fn connect_unix(fd int, path string) intconnectUnix 时间。失败时 throw。
fd intpath stringint — 该类型的值
listenpub fn listen(fd int, backlog int) int开始监听。失败时 throw。
fd intbacklog intint — 该类型的值
acceptpub fn accept(fd int) int接受一个连接。失败时 throw。
fd intint — 该类型的值
sendtopub fn sendto(fd int, addr string, data string) int发送数据报。失败时 throw。
fd intaddr stringdata stringint — 该类型的值
recvfrompub fn recvfrom(fd int, max int) string收数据报。失败时 throw。
fd intmax intstring — 结果字符串
fd_readpub fn fd_read(fd int, max int) string从 fd 读。失败时 throw。
fd intmax intstring — 结果字符串
fd_writepub fn fd_write(fd int, data string) int向 fd 写。失败时 throw。
fd intdata stringint — 该类型的值
fd_closepub fn fd_close(fd int) int关 fd。失败时 throw。
fd intint — 该类型的值
socket_readpub fn socket_read(fd int, max int) string读取套接字。失败时 throw。
fd intmax intstring — 结果字符串
socket_writepub fn socket_write(fd int, data string) int写入套接字。失败时 throw。
fd intdata stringint — 该类型的值
socket_closepub fn socket_close(fd int) int关闭套接字。失败时 throw。
fd intint — 该类型的值
set_sock_timeoutpub fn set_sock_timeout(fd int, ns int) int设置 sock timeout。失败时 throw。
fd intns intint — 该类型的值
interface_datapub fn interface_data(name string) string网卡data。失败时 throw。
name stringstring — 结果字符串
(&File) read_npub fn (f &File) read_n(n int) string`&File` 上的方法:最多读 n 字节;到末尾可返回更短或空串。失败时 throw。
f &Filen intstring — 结果字符串
(&File) write_strpub fn (f &File) write_str(data string) int`&File` 上的方法:写入字符串。失败时 throw。
f &Filedata stringint — 该类型的值