Documentation ¶
Index ¶
- Constants
- func GetScriptArgs() []string
- func MassagePathError(basePath string, err error) error
- func ResolvePath(base, path, op string) (string, error)
- func SetScriptArgs(args []string)
- func WithOS(ctx context.Context, osObj OS) context.Context
- type BufferFile
- func (f *BufferFile) Bytes() []byte
- func (f *BufferFile) Close() error
- func (f *BufferFile) Read(p []byte) (n int, err error)
- func (f *BufferFile) ReadAt(p []byte, off int64) (n int, err error)
- func (f *BufferFile) Seek(offset int64, whence int) (int64, error)
- func (f *BufferFile) Stat() (FileInfo, error)
- func (f *BufferFile) Write(p []byte) (n int, err error)
- type DirEntry
- type DirEntryWrapper
- type ExitHandler
- type FS
- type File
- type FileInfo
- type FileMode
- type GenericDirEntry
- type GenericDirEntryOpts
- type GenericFileInfo
- type GenericFileInfoOpts
- type InMemoryFile
- func (b *InMemoryFile) Bytes() []byte
- func (f *InMemoryFile) Close() error
- func (f *InMemoryFile) Len() int
- func (f *InMemoryFile) Read(p []byte) (int, error)
- func (f *InMemoryFile) ReadAt(p []byte, off int64) (int, error)
- func (f *InMemoryFile) Rewind()
- func (f *InMemoryFile) Seek(pos int)
- func (f *InMemoryFile) Stat() (FileInfo, error)
- func (f *InMemoryFile) Write(p []byte) (int, error)
- type Mount
- type NilFile
- func (f *NilFile) Close() error
- func (f *NilFile) Read(p []byte) (n int, err error)
- func (f *NilFile) ReadAt(p []byte, off int64) (n int, err error)
- func (f *NilFile) Seek(offset int64, whence int) (int64, error)
- func (f *NilFile) Stat() (FileInfo, error)
- func (f *NilFile) Write(p []byte) (n int, err error)
- type OS
- type Option
- func WithArgs(args []string) Option
- func WithCwd(cwd string) Option
- func WithEnvironment(env map[string]string) Option
- func WithExitHandler(exitHandler ExitHandler) Option
- func WithHostname(hostname string) Option
- func WithMounts(mounts map[string]*Mount) Option
- func WithPid(pid int) Option
- func WithStdin(stdin File) Option
- func WithStdout(stdout File) Option
- func WithTmp(tmp string) Option
- func WithUid(uid int) Option
- func WithUserCacheDir(dir string) Option
- func WithUserConfigDir(dir string) Option
- func WithUserHomeDir(dir string) Option
- type ReadDirFile
- type SimpleOS
- func (osObj *SimpleOS) Args() []string
- func (osObj *SimpleOS) Chdir(dir string) error
- func (osObj *SimpleOS) Create(name string) (File, error)
- func (osObj *SimpleOS) Environ() []string
- func (osObj *SimpleOS) Exit(code int)
- func (osObj *SimpleOS) Getenv(key string) string
- func (osObj *SimpleOS) Getpid() int
- func (osObj *SimpleOS) Getuid() int
- func (osObj *SimpleOS) Getwd() (string, error)
- func (osObj *SimpleOS) Hostname() (string, error)
- func (osObj *SimpleOS) LookupEnv(key string) (string, bool)
- func (osObj *SimpleOS) Mkdir(name string, perm FileMode) error
- func (osObj *SimpleOS) MkdirAll(path string, perm FileMode) error
- func (osObj *SimpleOS) MkdirTemp(dir, pattern string) (string, error)
- func (osObj *SimpleOS) Open(name string) (File, error)
- func (osObj *SimpleOS) OpenFile(name string, flag int, perm FileMode) (File, error)
- func (osObj *SimpleOS) PathListSeparator() rune
- func (osObj *SimpleOS) PathSeparator() rune
- func (osObj *SimpleOS) ReadDir(name string) ([]DirEntry, error)
- func (osObj *SimpleOS) ReadFile(name string) ([]byte, error)
- func (osObj *SimpleOS) Remove(name string) error
- func (osObj *SimpleOS) RemoveAll(path string) error
- func (osObj *SimpleOS) Rename(oldpath, newpath string) error
- func (osObj *SimpleOS) Setenv(key, value string) error
- func (osObj *SimpleOS) Stat(name string) (os.FileInfo, error)
- func (osObj *SimpleOS) Stdin() File
- func (osObj *SimpleOS) Stdout() File
- func (osObj *SimpleOS) Symlink(oldname, newname string) error
- func (osObj *SimpleOS) TempDir() string
- func (osObj *SimpleOS) Unsetenv(key string) error
- func (osObj *SimpleOS) UserCacheDir() (string, error)
- func (osObj *SimpleOS) UserConfigDir() (string, error)
- func (osObj *SimpleOS) UserHomeDir() (string, error)
- func (osObj *SimpleOS) WalkDir(root string, fn WalkDirFunc) error
- func (osObj *SimpleOS) WriteFile(name string, data []byte, perm FileMode) error
- type VirtualOS
- func (osObj *VirtualOS) Args() []string
- func (osObj *VirtualOS) Chdir(dir string) error
- func (osObj *VirtualOS) Create(name string) (File, error)
- func (osObj *VirtualOS) Environ() []string
- func (osObj *VirtualOS) Exit(code int)
- func (osObj *VirtualOS) Getenv(key string) string
- func (osObj *VirtualOS) Getpid() int
- func (osObj *VirtualOS) Getuid() int
- func (osObj *VirtualOS) Getwd() (string, error)
- func (osObj *VirtualOS) Hostname() (string, error)
- func (osObj *VirtualOS) LookupEnv(key string) (string, bool)
- func (osObj *VirtualOS) Mkdir(name string, perm FileMode) error
- func (osObj *VirtualOS) MkdirAll(path string, perm FileMode) error
- func (osObj *VirtualOS) MkdirTemp(dir, pattern string) (string, error)
- func (osObj *VirtualOS) Open(name string) (File, error)
- func (osObj *VirtualOS) OpenFile(name string, flag int, perm FileMode) (File, error)
- func (osObj *VirtualOS) PathListSeparator() rune
- func (osObj *VirtualOS) PathSeparator() rune
- func (osObj *VirtualOS) ReadDir(name string) ([]DirEntry, error)
- func (osObj *VirtualOS) ReadFile(name string) ([]byte, error)
- func (osObj *VirtualOS) Remove(name string) error
- func (osObj *VirtualOS) RemoveAll(path string) error
- func (osObj *VirtualOS) Rename(oldpath, newpath string) error
- func (osObj *VirtualOS) SetArgs(args []string)
- func (osObj *VirtualOS) Setenv(key, value string) error
- func (osObj *VirtualOS) Stat(name string) (os.FileInfo, error)
- func (osObj *VirtualOS) Stdin() File
- func (osObj *VirtualOS) Stdout() File
- func (osObj *VirtualOS) Symlink(oldname, newname string) error
- func (osObj *VirtualOS) TempDir() string
- func (osObj *VirtualOS) Unsetenv(key string) error
- func (osObj *VirtualOS) UserCacheDir() (string, error)
- func (osObj *VirtualOS) UserConfigDir() (string, error)
- func (osObj *VirtualOS) UserHomeDir() (string, error)
- func (osObj *VirtualOS) WalkDir(root string, fn WalkDirFunc) error
- func (osObj *VirtualOS) WriteFile(name string, data []byte, perm FileMode) error
- type WalkDirFunc
Constants ¶
const ( // Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified. O_RDONLY int = syscall.O_RDONLY // open the file read-only. O_WRONLY int = syscall.O_WRONLY // open the file write-only. O_RDWR int = syscall.O_RDWR // open the file read-write. // The remaining values may be or'ed in to control behavior. O_APPEND int = syscall.O_APPEND // append data to the file when writing. O_CREATE int = syscall.O_CREAT // create a new file if none exists. O_EXCL int = syscall.O_EXCL // used with O_CREATE, file must not exist. O_SYNC int = syscall.O_SYNC // open for synchronous I/O. O_TRUNC int = syscall.O_TRUNC // truncate regular writable file when opened. )
Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
Variables ¶
This section is empty.
Functions ¶
func GetScriptArgs ¶ added in v1.1.0
func GetScriptArgs() []string
if risor is started from the command line and args are passed in, this is is how the to get them
func MassagePathError ¶
MassagePathError transforms a fs.PathError into a new one with the base path removed from the Path field.
func ResolvePath ¶
ResolvePath resolves a path relative to a base path. An error is returned if the path is invalid.
func SetScriptArgs ¶ added in v1.1.0
func SetScriptArgs(args []string)
if risor is started from the command line and args are passed in, this is is how the to tell the os package about them
Types ¶
type BufferFile ¶ added in v1.3.2
type BufferFile struct {
// contains filtered or unexported fields
}
BufferFile is an in memory file backed by a bytes buffer Writes to this file are append only and seek is not supported
func NewBufferFile ¶ added in v1.3.2
func NewBufferFile(data []byte) *BufferFile
func (*BufferFile) Bytes ¶ added in v1.3.2
func (f *BufferFile) Bytes() []byte
func (*BufferFile) Close ¶ added in v1.3.2
func (f *BufferFile) Close() error
func (*BufferFile) ReadAt ¶ added in v1.3.2
func (f *BufferFile) ReadAt(p []byte, off int64) (n int, err error)
func (*BufferFile) Seek ¶ added in v1.3.2
func (f *BufferFile) Seek(offset int64, whence int) (int64, error)
func (*BufferFile) Stat ¶ added in v1.3.2
func (f *BufferFile) Stat() (FileInfo, error)
type DirEntryWrapper ¶
func (*DirEntryWrapper) HasInfo ¶
func (de *DirEntryWrapper) HasInfo() bool
type ExitHandler ¶
type ExitHandler func(int)
type FS ¶
type FS interface { Create(name string) (File, error) Mkdir(name string, perm FileMode) error MkdirAll(path string, perm FileMode) error Open(name string) (File, error) OpenFile(name string, flag int, perm FileMode) (File, error) ReadFile(name string) ([]byte, error) Remove(name string) error RemoveAll(path string) error Rename(oldpath, newpath string) error Stat(name string) (FileInfo, error) Symlink(oldname, newname string) error WriteFile(name string, data []byte, perm FileMode) error ReadDir(name string) ([]DirEntry, error) WalkDir(root string, fn WalkDirFunc) error }
type GenericDirEntry ¶
type GenericDirEntry struct {
// contains filtered or unexported fields
}
func NewDirEntry ¶
func NewDirEntry(opts GenericDirEntryOpts) *GenericDirEntry
func (*GenericDirEntry) HasInfo ¶
func (de *GenericDirEntry) HasInfo() bool
func (*GenericDirEntry) Info ¶
func (de *GenericDirEntry) Info() (FileInfo, error)
func (*GenericDirEntry) IsDir ¶
func (de *GenericDirEntry) IsDir() bool
func (*GenericDirEntry) Name ¶
func (de *GenericDirEntry) Name() string
func (*GenericDirEntry) Type ¶
func (de *GenericDirEntry) Type() FileMode
type GenericDirEntryOpts ¶
type GenericDirEntryOpts struct { Name string Mode FileMode Info *GenericFileInfo }
type GenericFileInfo ¶
type GenericFileInfo struct {
// contains filtered or unexported fields
}
func NewFileInfo ¶
func NewFileInfo(opts GenericFileInfoOpts) *GenericFileInfo
func (*GenericFileInfo) IsDir ¶
func (fi *GenericFileInfo) IsDir() bool
func (*GenericFileInfo) ModTime ¶
func (fi *GenericFileInfo) ModTime() time.Time
func (*GenericFileInfo) Mode ¶
func (fi *GenericFileInfo) Mode() FileMode
func (*GenericFileInfo) Name ¶
func (fi *GenericFileInfo) Name() string
func (*GenericFileInfo) Size ¶
func (fi *GenericFileInfo) Size() int64
func (*GenericFileInfo) Sys ¶
func (fi *GenericFileInfo) Sys() interface{}
type GenericFileInfoOpts ¶
type InMemoryFile ¶ added in v0.10.0
type InMemoryFile struct {
// contains filtered or unexported fields
}
InMemoryFile is an in-memory file backed by a slice of bytes with support for seek
func NewInMemoryFile ¶ added in v0.10.0
func NewInMemoryFile(data []byte) *InMemoryFile
func (*InMemoryFile) Bytes ¶ added in v0.10.0
func (b *InMemoryFile) Bytes() []byte
Bytes returns the underlying bytes from the current position.
func (*InMemoryFile) Close ¶ added in v0.10.0
func (f *InMemoryFile) Close() error
Close clears all the data out of the file and sets the read position to 0.
func (*InMemoryFile) Len ¶ added in v1.3.2
func (f *InMemoryFile) Len() int
Len returns the length of data remaining to be read.
func (*InMemoryFile) Read ¶ added in v0.10.0
func (f *InMemoryFile) Read(p []byte) (int, error)
Read reads the next len(p) bytes from the file or until the end is reached.
func (*InMemoryFile) ReadAt ¶ added in v0.10.0
func (f *InMemoryFile) ReadAt(p []byte, off int64) (int, error)
ReadAt reads len(b) bytes from the File starting at byte offset off. It returns the number of bytes read and the read pointer is not modified.
func (*InMemoryFile) Rewind ¶ added in v1.3.2
func (f *InMemoryFile) Rewind()
Rewind resets the read pointer to 0.
func (*InMemoryFile) Seek ¶ added in v0.10.0
func (f *InMemoryFile) Seek(pos int)
Seek sets the read pointer to pos.
func (*InMemoryFile) Stat ¶ added in v0.10.0
func (f *InMemoryFile) Stat() (FileInfo, error)
type NilFile ¶ added in v0.10.0
type NilFile struct{}
type OS ¶
type OS interface { FS Args() []string Chdir(dir string) error Environ() []string Exit(code int) Getenv(key string) string Getpid() int Getuid() int Getwd() (dir string, err error) Hostname() (name string, err error) LookupEnv(key string) (string, bool) MkdirTemp(dir, pattern string) (string, error) Setenv(key, value string) error TempDir() string Unsetenv(key string) error UserCacheDir() (string, error) UserConfigDir() (string, error) UserHomeDir() (string, error) Stdin() File Stdout() File PathSeparator() rune PathListSeparator() rune }
func GetDefaultOS ¶ added in v0.10.0
GetDefaultOS returns the OS from the context, if it exists. Otherwise, it returns a new SimpleOS.
type Option ¶
type Option func(*VirtualOS)
Option is a configuration function for a Virtual Machine.
func WithEnvironment ¶
WithEnvironment sets the user home directory.
func WithExitHandler ¶
func WithExitHandler(exitHandler ExitHandler) Option
WithExitHandler sets the exit handler.
func WithUserCacheDir ¶
WithUserCacheDir sets the user cache directory.
func WithUserConfigDir ¶
WithUserConfigDir sets the user config directory.
func WithUserHomeDir ¶
WithUserHomeDir sets the user home directory.
type ReadDirFile ¶
type ReadDirFile = fs.ReadDirFile
type SimpleOS ¶
type SimpleOS struct {
// contains filtered or unexported fields
}
func NewSimpleOS ¶
func (*SimpleOS) PathListSeparator ¶ added in v1.3.0
func (*SimpleOS) PathSeparator ¶ added in v1.3.0
func (*SimpleOS) UserCacheDir ¶
func (*SimpleOS) UserConfigDir ¶
func (*SimpleOS) UserHomeDir ¶
type VirtualOS ¶
type VirtualOS struct {
// contains filtered or unexported fields
}
func NewVirtualOS ¶
NewVirtualOS creates a new VirtualOS configured with the given options.
func (*VirtualOS) PathListSeparator ¶ added in v1.3.0
func (*VirtualOS) PathSeparator ¶ added in v1.3.0
func (*VirtualOS) SetArgs ¶ added in v1.1.0
a way to override or set the args passed to the os package would typically be used when risor is employed in an embedded manner
func (*VirtualOS) UserCacheDir ¶
func (*VirtualOS) UserConfigDir ¶
func (*VirtualOS) UserHomeDir ¶
type WalkDirFunc ¶ added in v1.2.0
type WalkDirFunc = fs.WalkDirFunc