updating documents for stdlib
This commit is contained in:
parent
306fe1b24c
commit
591d745ef7
5 changed files with 182 additions and 196 deletions
|
@ -67,7 +67,7 @@ var mathModule = map[string]objects.Object{
|
||||||
"sqrt": FuncAFRF(math.Sqrt),
|
"sqrt": FuncAFRF(math.Sqrt),
|
||||||
"tan": FuncAFRF(math.Tan),
|
"tan": FuncAFRF(math.Tan),
|
||||||
"tanh": FuncAFRF(math.Tanh),
|
"tanh": FuncAFRF(math.Tanh),
|
||||||
"runct": FuncAFRF(math.Trunc),
|
"trunc": FuncAFRF(math.Trunc),
|
||||||
"y0": FuncAFRF(math.Y0),
|
"y0": FuncAFRF(math.Y0),
|
||||||
"y1": FuncAFRF(math.Y1),
|
"y1": FuncAFRF(math.Y1),
|
||||||
"yn": FuncAIFRF(math.Yn),
|
"yn": FuncAIFRF(math.Yn),
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
# Module - "exec"
|
|
||||||
|
|
||||||
```golang
|
|
||||||
exec := import("exec")
|
|
||||||
```
|
|
||||||
|
|
||||||
## Module Functions
|
|
||||||
|
|
||||||
- `look_path(file string) => string/error`: port of `exec.LookPath` function
|
|
||||||
- `command(name string, args array(string)) => `Cmd/error`: port of `exec.Command` function
|
|
||||||
|
|
||||||
## Cmd Functions
|
|
||||||
|
|
||||||
```golang
|
|
||||||
cmd := exec.command("echo", ["foo", "bar"])
|
|
||||||
output := cmd.output()
|
|
||||||
```
|
|
||||||
|
|
||||||
- `combined_output() => bytes/error`: port of `exec.Cmd.CombinedOutput` function
|
|
||||||
- `output() => bytes/error`: port of `exec.Cmd.Output` function
|
|
||||||
- `combined_output() => bytes/error`: port of `exec.Cmd.CombinedOutput` function
|
|
||||||
- `run() => error`: port of `exec.Cmd.Run` function
|
|
||||||
- `start() => error`: port of `exec.Cmd.Start` function
|
|
||||||
- `wait() => error`: port of `exec.Cmd.Wait` function
|
|
||||||
- `set_path(path string)`: sets `Path` of `exec.Cmd`
|
|
||||||
- `set_dir(dir string)`: sets `Dir` of `exec.Cmd`
|
|
||||||
- `set_env(env array(string))`: sets `Env` of `exec.Cmd`
|
|
||||||
- `process() => Process`: returns Process (`Process` of `exec.Cmd`)
|
|
|
@ -4,76 +4,72 @@
|
||||||
math := import("math")
|
math := import("math")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Variables
|
## Constants
|
||||||
|
|
||||||
- `e`: equivalent of Go's `math.E`
|
- `e`
|
||||||
- `pi`: equivalent of Go's `math.Pi`
|
- `pi`
|
||||||
- `phi`: equivalent of Go's `math.Phi`
|
- `phi`
|
||||||
- `sqrt2`: equivalent of Go's `math.Sqrt2`
|
- `sqrt2`
|
||||||
- `sqrtE`: equivalent of Go's `math.SqrtE`
|
- `sqrtE`
|
||||||
- `sprtPi`: equivalent of Go's `math.SqrtPi`
|
- `sprtPi`
|
||||||
- `sqrtPhi`: equivalent of Go's `math.SqrtPhi`
|
- `sqrtPhi`
|
||||||
- `ln2`: equivalent of Go's `math.Ln2`
|
- `ln2`
|
||||||
- `log2E`: equivalent of Go's `math.Log2E`
|
- `log2E`
|
||||||
- `ln10`: equivalent of Go's `math.Ln10`
|
- `ln10`
|
||||||
- `ln10E`: equivalent of Go's `math.Log10E`
|
- `ln10E`
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
- `abs(float) => float`: port of Go's `math.Abs` function
|
- `abs(x float) => float`: returns the absolute value of x.
|
||||||
- `acos(float) => float`: port of Go's `math.Acos` function
|
- `acos(x float) => float`: returns the arccosine, in radians, of x.
|
||||||
- `acosh(float) => float`: port of Go's `math.Acosh` function
|
- `acosh(x float) => float`: returns the inverse hyperbolic cosine of x.
|
||||||
- `asin(float) => float`: port of Go's `math.Asin` function
|
- `asin(x float) => float`: returns the arcsine, in radians, of x.
|
||||||
- `asinh(float) => float`: port of Go's `math.Asinh` function
|
- `asinh(x float) => float`: returns the inverse hyperbolic sine of x.
|
||||||
- `atan(float) => float`: port of Go's `math.Atan` function
|
- `atan(x float) => float`: returns the arctangent, in radians, of x.
|
||||||
- `atan2(float, float) => float`: port of Go's `math.Atan2` function
|
- `atan2(y float, xfloat) => float`: returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.
|
||||||
- `atanh(float) => float`: port of Go's `math.Atanh` function
|
- `atanh(x float) => float`: returns the inverse hyperbolic tangent of x.
|
||||||
- `cbrt(float) => float`: port of Go's `math.Cbrt` function
|
- `cbrt(x float) => float`: returns the cube root of x.
|
||||||
- `ceil(float) => float`: port of Go's `math.Ceil` function
|
- `ceil(x float) => float`: returns the least integer value greater than or equal to x.
|
||||||
- `copysign(float, float) => float`: port of Go's `math.Copysign` function
|
- `copysign(x float, y float) => float`: returns a value with the magnitude of x and the sign of y.
|
||||||
- `cos(float) => float`: port of Go's `math.Cos` function
|
- `cos(x float) => float`: returns the cosine of the radian argument x.
|
||||||
- `cosh(float) => float`: port of Go's `math.Cosh` function
|
- `cosh(x float) => float`: returns the hyperbolic cosine of x.
|
||||||
- `dim(float, float) => float`: port of Go's `math.Dim` function
|
- `dim(x float, y float) => float`: returns the maximum of x-y or 0.
|
||||||
- `erf(float) => float`: port of Go's `math.Erf` function
|
- `erf(x float) => float`: returns the error function of x.
|
||||||
- `erfc(float) => float`: port of Go's `math.Erfc` function
|
- `erfc(x float) => float`: returns the complementary error function of x.
|
||||||
- `erfcinv(float) => float`: port of Go's `math.Erfcinv` function
|
- `exp(x float) => float`: returns e**x, the base-e exponential of x.
|
||||||
- `erfinv(float) => float`: port of Go's `math.Erfinv` function
|
- `exp2(x float) => float`: returns 2**x, the base-2 exponential of x.
|
||||||
- `exp(float) => float`: port of Go's `math.Exp` function
|
- `expm1(x float) => float`: returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than Exp(x) - 1 when x is near zero.
|
||||||
- `exp2(float) => float`: port of Go's `math.Exp2` function
|
- `floor(x float) => float`: returns the greatest integer value less than or equal to x.
|
||||||
- `expm1(float) => float`: port of Go's `math.Expm1` function
|
- `gamma(x float) => float`: returns the Gamma function of x.
|
||||||
- `floor(float) => float`: port of Go's `math.Floor` function
|
- `hypot(p float, q float) => float`: returns Sqrt(p * p + q * q), taking care to avoid unnecessary overflow and underflow.
|
||||||
- `gamma(float) => float`: port of Go's `math.Gamma` function
|
- `ilogb(x float) => float`: returns the binary exponent of x as an integer.
|
||||||
- `hypot(float, float) => float`: port of Go's `math.Hypot` function
|
- `inf(sign int) => float`: returns positive infinity if sign >= 0, negative infinity if sign < 0.
|
||||||
- `ilogb(float) => float`: port of Go's `math.Ilogb` function
|
- `is_inf(f float, sign int) => float`: reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.
|
||||||
- `inf(int) => float`: port of Go's `math.Inf` function
|
- `is_nan(f float) => float`: reports whether f is an IEEE 754 ``not-a-number'' value.
|
||||||
- `is_inf(float, int) => float`: port of Go's `math.IsInf` function
|
- `j0(x float) => float`: returns the order-zero Bessel function of the first kind.
|
||||||
- `is_nan(float) => float`: port of Go's `math.IsNaN` function
|
- `j1(x float) => float`: returns the order-one Bessel function of the first kind.
|
||||||
- `j0(float) => float`: port of Go's `math.J0` function
|
- `jn(n int, x float) => float`: returns the order-n Bessel function of the first kind.
|
||||||
- `j1(float) => float`: port of Go's `math.J1` function
|
- `ldexp(frac float, exp int) => float`: is the inverse of frexp. It returns frac × 2**exp.
|
||||||
- `jn(int, float) => float`: port of Go's `math.Jn` function
|
- `log(x float) => float`: returns the natural logarithm of x.
|
||||||
- `ldexp(float, int) => float`: port of Go's `math.Ldexp` function
|
- `log10(x float) => float`: returns the decimal logarithm of x.
|
||||||
- `log(float) => float`: port of Go's `math.Log` function
|
- `log1p(x float) => float`: returns the natural logarithm of 1 plus its argument x. It is more accurate than Log(1 + x) when x is near zero.
|
||||||
- `log10(float) => float`: port of Go's `math.Log10` function
|
- `log2(x float) => float`: returns the binary logarithm of x.
|
||||||
- `log1p(float) => float`: port of Go's `math.Log1p` function
|
- `logb(x float) => float`: returns the binary exponent of x.
|
||||||
- `log2(float) => float`: port of Go's `math.Log2` function
|
- `max(x float, y float) => float`: returns the larger of x or y.
|
||||||
- `logb(float) => float`: port of Go's `math.Logb` function
|
- `min(x float, y float) => float`: returns the smaller of x or y.
|
||||||
- `max(float, float) => float`: port of Go's `math.Max` function
|
- `mod(x float, y float) => float`: returns the floating-point remainder of x/y.
|
||||||
- `min(float, float) => float`: port of Go's `math.Min` function
|
- `nan() => float`: returns an IEEE 754 ``not-a-number'' value.
|
||||||
- `mod(float, float) => float`: port of Go's `math.Mod` function
|
- `nextafter(x float, y float) => float`: returns the next representable float64 value after x towards y.
|
||||||
- `nan() => float`: port of Go's `math.NaN` function
|
- `pow(x float, y float) => float`: returns x**y, the base-x exponential of y.
|
||||||
- `nextafter(float, float) => float`: port of Go's `math.Nextafter` function
|
- `pow10(n int) => float`: returns 10**n, the base-10 exponential of n.
|
||||||
- `pow(float, float) => float`: port of Go's `math.Pow` function
|
- `remainder(x float, y float) => float`: returns the IEEE 754 floating-point remainder of x/y.
|
||||||
- `pow10(int) => float`: port of Go's `math.Pow10` function
|
- `signbit(x float) => float`: returns true if x is negative or negative zero.
|
||||||
- `remainder(float, float) => float`: port of Go's `math.Remainder` function
|
- `sin(x float) => float`: returns the sine of the radian argument x.
|
||||||
- `round(float) => float`: port of Go's `math.Round` function
|
- `sinh(x float) => float`: returns the hyperbolic sine of x.
|
||||||
- `round_to_even(float) => float`: port of Go's `math.RoundToEven` function
|
- `sqrt(x float) => float`: returns the square root of x.
|
||||||
- `signbit(float) => float`: port of Go's `math.Signbit` function
|
- `tan(x float) => float`: returns the tangent of the radian argument x.
|
||||||
- `sin(float) => float`: port of Go's `math.Sin` function
|
- `tanh(x float) => float`: returns the hyperbolic tangent of x.
|
||||||
- `sinh(float) => float`: port of Go's `math.Sinh` function
|
- `trunc(x float) => float`: returns the integer value of x.
|
||||||
- `sqrt(float) => float`: port of Go's `math.Sqrt` function
|
- `y0(x float) => float`: returns the order-zero Bessel function of the second kind.
|
||||||
- `tan(float) => float`: port of Go's `math.Tan` function
|
- `y1(x float) => float`: returns the order-one Bessel function of the second kind.
|
||||||
- `tanh(float) => float`: port of Go's `math.Tanh` function
|
- `yn(n int, x float) => float`: returns the order-n Bessel function of the second kind.
|
||||||
- `runct(float) => float`: port of Go's `math.Trunc` function
|
|
||||||
- `y0(float) => float`: port of Go's `math.Y0` function
|
|
||||||
- `y1(float) => float`: port of Go's `math.Y1` function
|
|
||||||
- `yn(int, float) => float`: port of Go's `math.Yn` function
|
|
|
@ -4,82 +4,84 @@
|
||||||
os := import("os")
|
os := import("os")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Module Variables
|
## Constants
|
||||||
|
|
||||||
- `o_rdonly`: equivalent of Go's `os.O_RDONLY`
|
- `o_rdonly`
|
||||||
- `o_wronly`: equivalent of Go's `os.O_WRONLY`
|
- `o_wronly`
|
||||||
- `o_rdwr`: equivalent of Go's `os.O_RDWR`
|
- `o_rdwr`
|
||||||
- `o_append`: equivalent of Go's `os.O_APPEND`
|
- `o_append`
|
||||||
- `o_create`: equivalent of Go's `os.O_CREATE`
|
- `o_create`
|
||||||
- `o_excl`: equivalent of Go's `os.O_EXCL`
|
- `o_excl`
|
||||||
- `o_sync`: equivalent of Go's `os.O_SYNC`
|
- `o_sync`
|
||||||
- `o_trunc`: equivalent of Go's `os.O_TRUNC`
|
- `o_trunc`
|
||||||
- `mode_dir`: equivalent of Go's `os.ModeDir`
|
- `mode_dir`
|
||||||
- `mode_append`: equivalent of Go's `os.ModeAppend`
|
- `mode_append`
|
||||||
- `mode_exclusive`: equivalent of Go's `os.ModeExclusive`
|
- `mode_exclusive`
|
||||||
- `mode_temporary`: equivalent of Go's `os.ModeTemporary`
|
- `mode_temporary`
|
||||||
- `mode_symlink`: equivalent of Go's `os.ModeSymlink`
|
- `mode_symlink`
|
||||||
- `mode_device`: equivalent of Go's `os.ModeDevice`
|
- `mode_device`
|
||||||
- `mode_named_pipe`: equivalent of Go's `os.ModeNamedPipe`
|
- `mode_named_pipe`
|
||||||
- `mode_socket`: equivalent of Go's `os.ModeSocket`
|
- `mode_socket`
|
||||||
- `mode_setuid`: equivalent of Go's `os.ModeSetuid`
|
- `mode_setuid`
|
||||||
- `mode_setgui`: equivalent of Go's `os.ModeSetgid`
|
- `mode_setgui`
|
||||||
- `mode_char_device`: equivalent of Go's `os.ModeCharDevice`
|
- `mode_char_device`
|
||||||
- `mode_sticky`: equivalent of Go's `os.ModeSticky`
|
- `mode_sticky`
|
||||||
- `mode_irregular`: equivalent of Go's `os.ModeIrregular`
|
- `mode_irregular`
|
||||||
- `mode_type`: equivalent of Go's `os.ModeType`
|
- `mode_type`
|
||||||
- `mode_perm`: equivalent of Go's `os.ModePerm`
|
- `mode_perm`
|
||||||
- `seek_set`: equivalent of Go's `os.SEEK_SET`
|
- `seek_set`
|
||||||
- `seek_cur`: equivalent of Go's `os.SEEK_CUR`
|
- `seek_cur`
|
||||||
- `seek_end`: equivalent of Go's `os.SEEK_END`
|
- `seek_end`
|
||||||
- `path_separator`: equivalent of Go's `os.PathSeparator`
|
- `path_separator`
|
||||||
- `path_list_separator`: equivalent of Go's `os.PathListSeparator`
|
- `path_list_separator`
|
||||||
- `dev_null`: equivalent of Go's `os.DevNull`
|
- `dev_null`
|
||||||
|
|
||||||
## Module Functions
|
|
||||||
|
|
||||||
- `args() => array(string)`: returns `os.Args`
|
## Functions
|
||||||
- `chdir(dir string) => error`: port of `os.Chdir` function
|
|
||||||
- `chmod(name string, mode int) => error `: port of Go's `os.Chmod` function
|
|
||||||
- `chown(name string, uid int, gid int) => error `: port of Go's `os.Chown` function
|
|
||||||
- `clearenv() `: port of Go's `os.Clearenv` function
|
|
||||||
- `environ() => array(string) `: port of Go's `os.Environ` function
|
|
||||||
- `executable() => string/error`: port of Go's `os.Executable()` function
|
|
||||||
- `exit(code int) `: port of Go's `os.Exit` function
|
|
||||||
- `expand_env(s string) => string `: port of Go's `os.ExpandEnv` function
|
|
||||||
- `getegid() => int `: port of Go's `os.Getegid` function
|
|
||||||
- `getenv(s string) => string `: port of Go's `os.Getenv` function
|
|
||||||
- `geteuid() => int `: port of Go's `os.Geteuid` function
|
|
||||||
- `getgid() => int `: port of Go's `os.Getgid` function
|
|
||||||
- `getgroups() => array(string)/error `: port of Go's `os.Getgroups` function
|
|
||||||
- `getpagesize() => int `: port of Go's `os.Getpagesize` function
|
|
||||||
- `getpid() => int `: port of Go's `os.Getpid` function
|
|
||||||
- `getppid() => int `: port of Go's `os.Getppid` function
|
|
||||||
- `getuid() => int `: port of Go's `os.Getuid` function
|
|
||||||
- `getwd() => string/error `: port of Go's `os.Getwd` function
|
|
||||||
- `hostname() => string/error `: port of Go's `os.Hostname` function
|
|
||||||
- `lchown(name string, uid int, gid int) => error `: port of Go's `os.Lchown` function
|
|
||||||
- `link(oldname string, newname string) => error `: port of Go's `os.Link` function
|
|
||||||
- `lookup_env(key string) => string/false`: port of Go's `os,LookupEnv` function
|
|
||||||
- `mkdir(name string, perm int) => error `: port of Go's `os.Mkdir` function
|
|
||||||
- `mkdir_all(name string, perm int) => error `: port of Go's `os.MkdirAll` function
|
|
||||||
- `readlink(name string) => string/error `: port of Go's `os.Readlink` function
|
|
||||||
- `remove(name string) => error `: port of Go's `os.Remove` function
|
|
||||||
- `remove_all(name string) => error `: port of Go's `os.RemoveAll` function
|
|
||||||
- `rename(oldpath string, newpath string) => error `: port of Go's `os.Rename` function
|
|
||||||
- `setenv(key string, value string) => error `: port of Go's `os.Setenv` function
|
|
||||||
- `symlink(oldname string newname string) => error `: port of Go's `os.Symlink` function
|
|
||||||
- `temp_dir() => string `: port of Go's `os.TempDir` function
|
|
||||||
- `truncate(name string, size int) => error `: port of Go's `os.Truncate` function
|
|
||||||
- `unsetenv(key string) => error `: port of Go's `os.Unsetenv` function
|
|
||||||
- `user_cache_dir() => string/error `: port of Go's `os.UserCacheDir` function
|
|
||||||
- `create(name string) => File/error`: port of Go's `os.Create` function
|
|
||||||
- `open(name string) => File/error`: port of Go's `os.Open` function
|
|
||||||
- `open_file(name string, flag int, perm int) => File/error`: port of Go's `os.OpenFile` function
|
|
||||||
- `find_process(pid int) => Process/error`: port of Go's `os.FindProcess` function
|
|
||||||
- `start_process(name string, argv array(string), dir string, env array(string)) => Process/error`: port of Go's `os.StartProcess` function
|
|
||||||
|
|
||||||
## File Functions
|
- `args() => [string]`: returns command-line arguments, starting with the program name.
|
||||||
|
- `chdir(dir string) => error`: changes the current working directory to the named directory.
|
||||||
|
- `chmod(name string, mode int) => error `: changes the mode of the named file to mode.
|
||||||
|
- `chown(name string, uid int, gid int) => error `: changes the numeric uid and gid of the named file.
|
||||||
|
- `clearenv()`: deletes all environment variables.
|
||||||
|
- `environ() => [string] `: returns a copy of strings representing the environment.
|
||||||
|
- `exit(code int) `: causes the current program to exit with the given status code.
|
||||||
|
- `expand_env(s string) => string `: replaces ${var} or $var in the string according to the values of the current environment variables.
|
||||||
|
- `getegid() => int `: returns the numeric effective group id of the caller.
|
||||||
|
- `getenv(key string) => string `: retrieves the value of the environment variable named by the key.
|
||||||
|
- `geteuid() => int `: returns the numeric effective user id of the caller.
|
||||||
|
- `getgid() => int `: returns the numeric group id of the caller.
|
||||||
|
- `getgroups() => [int]/error `: returns a list of the numeric ids of groups that the caller belongs to.
|
||||||
|
- `getpagesize() => int `: returns the underlying system's memory page size.
|
||||||
|
- `getpid() => int `: returns the process id of the caller.
|
||||||
|
- `getppid() => int `: returns the process id of the caller's parent.
|
||||||
|
- `getuid() => int `: returns the numeric user id of the caller.
|
||||||
|
- `getwd() => string/error `: returns a rooted path name corresponding to the current directory.
|
||||||
|
- `hostname() => string/error `: returns the host name reported by the kernel.
|
||||||
|
- `lchown(name string, uid int, gid int) => error `: changes the numeric uid and gid of the named file.
|
||||||
|
- `link(oldname string, newname string) => error `: creates newname as a hard link to the oldname file.
|
||||||
|
- `lookup_env(key string) => string/false`: retrieves the value of the environment variable named by the key.
|
||||||
|
- `mkdir(name string, perm int) => error `: creates a new directory with the specified name and permission bits (before umask).
|
||||||
|
- `mkdir_all(name string, perm int) => error `: creates a directory named path, along with any necessary parents, and returns nil, or else returns an error.
|
||||||
|
- `readlink(name string) => string/error `: returns the destination of the named symbolic link.
|
||||||
|
- `remove(name string) => error `: removes the named file or (empty) directory.
|
||||||
|
- `remove_all(name string) => error `: removes path and any children it contains.
|
||||||
|
- `rename(oldpath string, newpath string) => error `: renames (moves) oldpath to newpath.
|
||||||
|
- `setenv(key string, value string) => error `: sets the value of the environment variable named by the key.
|
||||||
|
- `symlink(oldname string newname string) => error `: creates newname as a symbolic link to oldname.
|
||||||
|
- `temp_dir() => string `: returns the default directory to use for temporary files.
|
||||||
|
- `truncate(name string, size int) => error `: changes the size of the named file.
|
||||||
|
- `unsetenv(key string) => error `: unsets a single environment variable.
|
||||||
|
- `create(name string) => File/error`: creates the named file with mode 0666 (before umask), truncating it if it already exists.
|
||||||
|
- `open(name string) => File/error`: 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.
|
||||||
|
- `open_file(name string, flag int, perm int) => File/error`: is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.) and perm (before umask), if applicable.
|
||||||
|
- `find_process(pid int) => Process/error`: looks for a running process by its pid.
|
||||||
|
- `start_process(name string, argv [string], dir string, env [string]) => Process/error`: 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.
|
||||||
|
- `exec_look_path(file string) => string/error`: searches for an executable named file in the directories named by the PATH environment variable.
|
||||||
|
- `exec(name string, args...) => Command/error`: returns the Command to execute the named program with the given arguments.
|
||||||
|
|
||||||
|
|
||||||
|
## File
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
file := os.create("myfile")
|
file := os.create("myfile")
|
||||||
|
@ -87,31 +89,31 @@ file.write_string("some data")
|
||||||
file.close()
|
file.close()
|
||||||
```
|
```
|
||||||
|
|
||||||
- `chdir() => true/error`: port of `os.File.Chdir` function
|
- `chdir() => true/error`: changes the current working directory to the file,
|
||||||
- `chown(uid int, gid int) => true/error`: port of `os.File.Chown` function
|
- `chown(uid int, gid int) => true/error`: changes the numeric uid and gid of the named file.
|
||||||
- `close() => error`: port of `os.File.Close` function
|
- `close() => error`: closes the File, rendering it unusable for I/O.
|
||||||
- `name() => string`: port of `os.File.Name` function
|
- `name() => string`: returns the name of the file as presented to Open.
|
||||||
- `readdirnames() => array(string)/error`: port of `os.File.Readdirnames` function
|
- `readdirnames(n int) => [string]/error`: reads and returns a slice of names from the directory.
|
||||||
- `sync() => error`: port of `os.File.Sync` function
|
- `sync() => error`: commits the current contents of the file to stable storage.
|
||||||
- `write(bytes) => int/error`: port of `os.File.Write` function
|
- `write(bytes) => int/error`: writes len(b) bytes to the File.
|
||||||
- `write_string(string) => int/error`: port of `os.File.WriteString` function
|
- `write_string(string) => int/error`: is like 'write', but writes the contents of string s rather than a slice of bytes.
|
||||||
- `read(bytes) => int/error`: port of `os.File.Read` function
|
- `read(bytes) => int/error`: reads up to len(b) bytes from the File.
|
||||||
- `chmod(mode int) => error`: port of `os.File.Chmod` function
|
- `chmod(mode int) => error`: changes the mode of the file to mode.
|
||||||
- `seek(offset int, whence int) => int/error`: port of `os.File.Seek` function
|
- `seek(offset int, whence int) => int/error`: 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.
|
||||||
|
|
||||||
## Process Functions
|
## Process
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
proc := start_process("app", ["arg1", "arg2"], "dir", [])
|
proc := start_process("app", ["arg1", "arg2"], "dir", [])
|
||||||
proc.wait()
|
proc.wait()
|
||||||
```
|
```
|
||||||
|
|
||||||
- `kill() => error`: port of `os.Process.Kill` function
|
- `kill() => error`: causes the Process to exit immediately.
|
||||||
- `release() => error`: port of `os.Process.Release` function
|
- `release() => error`: releases any resources associated with the process, rendering it unusable in the future.
|
||||||
- `signal(signal int) => error`: port of `os.Process.Signal` function
|
- `signal(signal int) => error`: sends a signal to the Process.
|
||||||
- `wait() => ProcessState/error`: port of `os.Process.Wait` function
|
- `wait() => ProcessState/error`: waits for the Process to exit, and then returns a ProcessState describing its status and an error, if any.
|
||||||
|
|
||||||
## ProcessState Functions
|
## ProcessState
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
proc := start_process("app", ["arg1", "arg2"], "dir", [])
|
proc := start_process("app", ["arg1", "arg2"], "dir", [])
|
||||||
|
@ -119,7 +121,24 @@ stat := proc.wait()
|
||||||
pid := stat.pid()
|
pid := stat.pid()
|
||||||
```
|
```
|
||||||
|
|
||||||
- `exited() => bool`: port of `os.ProcessState.Exited` function
|
- `exited() => bool`: reports whether the program has exited.
|
||||||
- `pid() => int`: port of `os.ProcessState.Pid` function
|
- `pid() => int`: returns the process id of the exited process.
|
||||||
- `string() => string`: port of `os.ProcessState.String` function
|
- `string() => string`: returns a string representation of the process.
|
||||||
- `success() => bool`: port of `os.ProcessState.Success` function
|
- `success() => bool`: reports whether the program exited successfully, such as with exit status 0 on Unix.
|
||||||
|
|
||||||
|
```golang
|
||||||
|
cmd := exec.command("echo", ["foo", "bar"])
|
||||||
|
output := cmd.output()
|
||||||
|
```
|
||||||
|
|
||||||
|
## Command
|
||||||
|
|
||||||
|
- `combined_output() => bytes/error`: runs the command and returns its combined standard output and standard error.
|
||||||
|
- `output() => bytes/error`: runs the command and returns its standard output.
|
||||||
|
- `run() => error`: starts the specified command and waits for it to complete.
|
||||||
|
- `start() => error`: starts the specified command but does not wait for it to complete.
|
||||||
|
- `wait() => error`: waits for the command to exit and waits for any copying to stdin or copying from stdout or stderr to complete.
|
||||||
|
- `set_path(path string)`: sets the path of the command to run.
|
||||||
|
- `set_dir(dir string)`: sets the working directory of the process.
|
||||||
|
- `set_env(env [string])`: sets the environment of the process.
|
||||||
|
- `process() => Process`: returns the underlying process, once started.
|
|
@ -1,7 +1,6 @@
|
||||||
# Standard Library
|
# Standard Library
|
||||||
|
|
||||||
_Warning: standard library implementations/interfaces are **experimental** and subject to change in the future release._
|
- [os](https://github.com/d5/tengo/blob/master/docs/stdlib-os.md): platform-independent interface to operating system functionality.
|
||||||
|
- [text](https://github.com/d5/tengo/blob/master/docs/stdlib-text.md): regular expressions, string conversion, and manipulation
|
||||||
- [math](https://github.com/d5/tengo/blob/master/docs/stdlib-math.md)
|
- [math](https://github.com/d5/tengo/blob/master/docs/stdlib-math.md): mathematical constants and functions
|
||||||
- [os](https://github.com/d5/tengo/blob/master/docs/stdlib-os.md)
|
- [times](https://github.com/d5/tengo/blob/master/docs/stdlib-times.md): time-related functions
|
||||||
- [exec](https://github.com/d5/tengo/blob/master/docs/stdlib-exec.md)
|
|
Loading…
Reference in a new issue