os

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2023 License: ISC Imports: 12 Imported by: 1

Documentation

Overview

Package os provides variadic function definitions for IO/OS builtins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStdHandle added in v0.9.0

func NewStdHandle(f *os.File) goal.V

NewStdHandle returns a buffered handle for the given file.

func VFChdir added in v0.10.0

func VFChdir(ctx *goal.Context, args []goal.V) goal.V

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

func VFClose(ctx *goal.Context, args []goal.V) goal.V

VFClose implements the close monad.

close h : closes a filehandle.

It returns a true value on success, and an error otherwise.

func VFEnv added in v0.10.0

func VFEnv(ctx *goal.Context, args []goal.V) goal.V

VFEnv implements the os.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

func VFFlush(ctx *goal.Context, args []goal.V) goal.V

VFFlush implements the flush monad.

flush h : flushes any buffered data to h.

It returns a true value on success.

func VFImport added in v0.10.0

func VFImport(ctx *goal.Context, args []goal.V) goal.V

VFImport implements the import dyad.

import s : evaluate file s+".goal" (or s if it has already an extension) with prefix s (without extension) for globals.

x import s : same as import s but use prefix x. If x is empty, no prefix is used.

It returns 0 and does nothing if a file has already been evaluated.

func VFOpen added in v0.10.0

func VFOpen(ctx *goal.Context, args []goal.V) goal.V

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", "r+", "w", "w+", "a", "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

func VFPrint(ctx *goal.Context, args []goal.V) goal.V

VFPrint implements the print dyad.

print x : outputs x to standard output. It returns a true value on success.

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

func VFRead(ctx *goal.Context, args []goal.V) goal.V

VFRead implements the read dyad.

read h : reads from filehandle h until EOF or an error occurs.

read s : reads file named s

s read h : reads from filehandle h until delimiter s or EOF, or an error occurs.

i read h : reads i bytes from filehandle 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 VFRun added in v0.10.0

func VFRun(ctx *goal.Context, args []goal.V) goal.V

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

func VFSay(ctx *goal.Context, args []goal.V) goal.V

VFSay implements the say dyad. It is the same as print, but appends a newline to the result.

func VFShell added in v0.10.0

func VFShell(ctx *goal.Context, args []goal.V) goal.V

VFShell implements the shell dyad. It works like the run dyad, but runs a single string command through /bin/sh instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL