os

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: ISC Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Stderr = newFile(os.Stderr)

Stderr represents the standard error filehandle.

View Source
var Stdin = newFile(os.Stdin)

Stdin represents the standard input filehandle.

View Source
var Stdout = newFile(os.Stdout)

Stdout represents the standard output filehandle.

Functions

func VClose added in v0.6.0

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

VClose implements the close monad.

close h : closes a filehandle.

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

func VEnv added in v0.6.0

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

VEnv 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 VFlush added in v0.6.0

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

VFlush implements the flush monad.

flush h : flushes any buffered data to h.

It returns a true value on success.

func VImport

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

VImport implements the import dyad.

import "name" : evaluate file "name.goal" with prefix "name"

pfx import "name" : evaluate file "name.goal" with custom prefix pfx

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

func VOpen added in v0.6.0

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

VOpen implements the open dyad.

open "path" : opens file "path" for reading.

mode open "path" : opens file "path" using the given fopen(3) mode.

mode can be: "r", "r+", "w", "w+", "a", "a+", "|-", "-|".

It returns a filehandle value of type "h" on success, and an error otherwise.

func VPrint

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

VPrint implements the print dyad.

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

h print y : outputs y to w, where w is an io.Writer or a filename (goal.S).

func VRead added in v0.6.0

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

VRead implements the read dyad.

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

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

n read h : reads n bytes from filehandle h until EOF (returning possibly less than n bytes) or an error occurs.

It returns the read content as a string on success, and an error otherwise.

func VRun added in v0.6.0

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

VRun 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.

In the first form, standard input, output, and error are inherited from the parent. It returns a true value on success, and an error otherwise.

In the second form, only standard error is inherited, and the command's standard output is returned.

func VSay

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

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

func VShell

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

VShell implements the shell monad.

shell cmd : sends cmd to the shell as-is. It returns the standard output of the command, or an error. Standard error is inherited from the parent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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