os

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: ISC Imports: 16 Imported by: 1

README

The package os provides variadic function definitions for IO/OS builtins.

This package offers quite simple IO functionality and is written in portable Go (except for code related to the shell builtin). However, to run the tests, you currently need a functional /bin/sh, git, and a goal executable in your $PATH.

Documentation

Overview

Package os provides Goal's default IO/OS builtins.

Use the Import function to register the variadic functions provided by this package.

Various variadic functions automatically work on new goal.BV value types as long as they satisfy the relevant interface:

io.Reader: read
io.Writer: print,say
io.Closer: close
fs.FS: all builtins accepting a file system value left
interface{ Flush() error }: flush
interface{ Stat() (fs.FileInfo, error) }: stat

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Import added in v0.39.0

func Import(ctx *goal.Context, pfx string)

Import registers in the given Context all the core Goal IO variadic functions as verbs with default names and valence. It also assigns command-line arguments and standard filehandles to globals.

If the given prefix string is not empty, it is used as a common dot prefix for names. Note, however, that the cmd/goal interpreter and library files in lib/ are designed to work together with an empty prefix.

Monads: abspath chdir close dirfs flush mkdir remove

Dyads: env glob import open print read rename run say shell stat subfs

Globals: ARGS STDIN STDOUT STDERR

Note that subfs comes from the io/fs package, but is registered for convenience by this function.

func NewDirFS added in v1.0.0

func NewDirFS(dir string) goal.V

NewDirFS returns a Goal value corresponding to dirfs dir.

func NewFileReader added in v0.25.0

func NewFileReader(f *os.File, buffered bool) goal.V

NewFileReader returns a reader handle for the given file. It may be buffered for non-directory files if enabled. It assumes the file has been opened in read mode.

func NewFileWriter added in v0.25.0

func NewFileWriter(f *os.File, buffered bool) goal.V

NewFileWriter returns a writer handle for the given file, using buffering if enabled. It assumes the file has been opened in write or append mode.

func NewOSError added in v1.0.0

func NewOSError(err error) goal.V

NewOSError converts an operating-system Go error to a Goal error dict value with fields as described in the FAQ.

func NewStringReader added in v1.0.0

func NewStringReader(s string) goal.V

NewStringReader returns a string reader handle Goal value for the given string.

func NewStringWriter added in v1.0.0

func NewStringWriter(i int) goal.V

NewStringWriter returns a string writer handle Goal value, with initial buffer of size i.

Types

This section is empty.

Jump to

Keyboard shortcuts

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