Documentation
¶
Overview ¶
Package os implements a subset of the Go "os" package. See https://godoc.org/os for details.
Note that the current implementation is blocking. This limitation should be removed in a future version.
Package os implements a subset of the Go "os" package. See https://godoc.org/os for details.
Note that the current implementation is blocking. This limitation should be removed in a future version.
Index ¶
- Constants
- Variables
- func Exit(code int)
- func Getpid() int
- func Getwd() (string, error)
- func IsExist(err error) bool
- func IsNotExist(err error) bool
- func IsPathSeparator(c uint8) bool
- func Mkdir(name string, perm FileMode) error
- func Readlink(name string) (string, error)
- func TempDir() string
- type File
- func (f *File) Close() error
- func (f *File) Fd() uintptr
- func (f *File) Read(b []byte) (n int, err error)
- func (f *File) Readdir(n int) ([]FileInfo, error)
- func (f *File) Readdirnames(n int) (names []string, err error)
- func (f *File) Stat() (FileInfo, error)
- func (f *File) Write(b []byte) (n int, err error)
- type FileInfo
- type FileMode
- type PathError
Constants ¶
const ( PathSeparator = '/' // OS-specific path separator PathListSeparator = ':' // OS-specific path list separator )
const ( O_RDONLY int = 1 O_WRONLY int = 2 O_RDWR int = 4 O_APPEND int = 8 O_CREATE int = 16 O_EXCL int = 32 O_SYNC int = 64 O_TRUNC int = 128 )
Stub constants
Variables ¶
var ( Stdin = &File{0, "/dev/stdin"} Stdout = &File{1, "/dev/stdout"} Stderr = &File{2, "/dev/stderr"} )
Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors.
Functions ¶
func Exit ¶ added in v0.7.0
func Exit(code int)
Exit causes the current program to exit with the given status code. Conventionally, code zero indicates success, non-zero an error. The program terminates immediately; deferred functions are not run.
func IsNotExist ¶ added in v0.7.0
IsNotExist is a stub (for now), always returning false
func IsPathSeparator ¶ added in v0.7.0
IsPathSeparator reports whether c is a directory separator character.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents an open file descriptor.
func Open ¶ added in v0.7.0
Open is a super simple stub function (for now), only capable of opening stdin, stdout, and stderr
func (*File) Fd ¶
Fd returns the integer Unix file descriptor referencing the open file. The file descriptor is valid only until f.Close is called.
func (*File) Read ¶
Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF.
func (*File) Readdirnames ¶ added in v0.7.0
Readdirnames is a stub, not yet implemented
type FileInfo ¶ added in v0.7.0
type FileInfo interface { Name() string // base name of the file Size() int64 // length in bytes for regular files; system-dependent for others Mode() FileMode // file mode bits // ModTime() time.Time // modification time IsDir() bool // abbreviation for Mode().IsDir() Sys() interface{} // underlying data source (can return nil) }
A FileInfo describes a file and is returned by Stat and Lstat.
type FileMode ¶ added in v0.7.0
type FileMode uint32
const ( // The single letters are the abbreviations used by the String method's formatting. ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory ModeAppend // a: append-only ModeExclusive // l: exclusive use ModeTemporary // T: temporary file; Plan 9 only ModeSymlink // L: symbolic link ModeDevice // D: device file ModeNamedPipe // p: named pipe (FIFO) ModeSocket // S: Unix domain socket ModeSetuid // u: setuid ModeSetgid // g: setgid ModeCharDevice // c: Unix character device, when ModeDevice is set ModeSticky // t: sticky ModeIrregular // ?: non-regular file; nothing else is known about this file // Mask for the type bits. For regular files, none will be set. ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice | ModeCharDevice | ModeIrregular ModePerm FileMode = 0777 // Unix permission bits )
Mode constants, copied from the mainline Go source https://github.com/golang/go/blob/4ce6a8e89668b87dce67e2f55802903d6eb9110a/src/os/types.go#L35-L63