Documentation ¶
Overview ¶
Package os provides variadic function definitions for IO/OS builtins.
Index ¶
- func NewFileReader(f *os.File) goal.V
- func NewFileWriter(f *os.File) goal.V
- func VFChdir(ctx *goal.Context, args []goal.V) goal.V
- func VFClose(ctx *goal.Context, args []goal.V) goal.V
- func VFEnv(ctx *goal.Context, args []goal.V) goal.V
- func VFFlush(ctx *goal.Context, args []goal.V) goal.V
- func VFImport(ctx *goal.Context, args []goal.V) goal.V
- func VFMkdir(ctx *goal.Context, args []goal.V) goal.V
- func VFOpen(ctx *goal.Context, args []goal.V) goal.V
- func VFPrint(ctx *goal.Context, args []goal.V) goal.V
- func VFRead(ctx *goal.Context, args []goal.V) goal.V
- func VFRemove(ctx *goal.Context, args []goal.V) goal.V
- func VFRename(ctx *goal.Context, args []goal.V) goal.V
- func VFRun(ctx *goal.Context, args []goal.V) goal.V
- func VFSay(ctx *goal.Context, args []goal.V) goal.V
- func VFShell(ctx *goal.Context, args []goal.V) goal.V
- func VFStat(ctx *goal.Context, args []goal.V) goal.V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileReader ¶ added in v0.25.0
NewFileReader returns a buffered reader handle for the given file.
func NewFileWriter ¶ added in v0.25.0
NewFileWriter returns a buffered writer handle for the given file.
func VFChdir ¶ added in v0.10.0
VFChdir implements the chdir monad.
chdir s : change current directory to s, or return an error.
It returns a true value on success.
func VFClose ¶ added in v0.10.0
VFClose implements the close monad.
close h : flush any buffered data, then close handle.
It returns a true value on success, and an error otherwise.
func VFEnv ¶ added in v0.10.0
VFEnv implements the env dyad.
env s : retrieve environment variable s, or return an error if unset. As a special case, "" returns a dictionary representing the whole environment.
x env s : sets the value of the environment variable x to s. It returns a true value of success, and an error otherwise. Also, the special form env[x;0] unsets a variable, and as a special case, env["";0] clears the whole environment.
func VFFlush ¶ added in v0.10.0
VFFlush implements the flush monad.
flush h : flushes any buffered data for handle.
It returns a true value on success, and an error otherwise.
func VFImport ¶ added in v0.10.0
VFImport implements the import dyad.
import s : read/eval wrapper roughly equivalent to eval[read path;path;pfx] where 1) path~s or path~env["GOALLIB"]+s+".goal" 2) pfx is path's basename without extension.
x import s : same as import s but use prefix x for globals. If x is empty, no prefix is used.
It returns 0 and does nothing if a file has already been evaluated.
func VFMkdir ¶ added in v0.25.0
VFMkdir implements the mkdir monad.
mkdir s : create directory s or return an error.
It returns the number of directories created, or an error.
func VFOpen ¶ added in v0.10.0
VFOpen implements the open dyad.
open "path" : opens file "path" for reading.
x open "path" : opens file "path" using the given fopen(3) mode x.
x can be: "r", "w", "a", "|-", "-|". In the last two modes, the path is instead interpreted as a command, and can be a list of strings.
It returns a filehandle value of type "h" on success, and an error otherwise.
func VFPrint ¶ added in v0.10.0
VFPrint implements the print dyad.
print x : outputs x to standard output. It returns a true value on success. It uses implicit conversion to string for non-string inputs.
x print y : outputs y to x, where x is an io.Writer handle or a filename (goal.S).
func VFRead ¶ added in v0.10.0
VFRead implements the read dyad.
read h : reads from handle h until EOF or an error occurs.
read s : reads file into string or directory into dictionary with keys "dir""mtime""size".
s read h : reads from handle h until delimiter s or EOF, or an error occurs.
i read h : reads i bytes from handle h until EOF (returning possibly less than i bytes) or an error occurs.
It returns the read content as a string on success, and an error otherwise.
func VFRemove ¶ added in v0.25.0
VFRemove implements the remove monad.
remove s : remove the named file or empty directory.
It returns the number of files removed, or an error.
func VFRename ¶ added in v0.25.0
VFRename implements the rename dyad.
rename[old;new] : rename path old to new.
It returns a true value on success, and an error otherwise.
func VFRun ¶ added in v0.10.0
VFRun implements the run monad.
run s : run command s, with arguments if s is an array.
x run s : run command s, with input string x as standard input.
In the first form, standard input and error are inherited from the parent. In the second form, only standard error is inherited. Both commands return their own standard output, or an error.
func VFSay ¶ added in v0.10.0
VFSay implements the say dyad. It is the same as print, but appends a newline to the result.
Types ¶
This section is empty.