os

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(protoAddr string) (net.Conn, error)

Connect dials the given address and returns a net.Conn. The protoAddr argument should be prefixed with the protocol, eg. "tcp://127.0.0.1:8080" or "unix:///tmp/test.sock"

func DirExists

func DirExists(dirPath string) bool

func EnsureDir

func EnsureDir(dir string, mode os.FileMode) error

func Exit

func Exit(s string)

func FileExists

func FileExists(filePath string) bool

Note: returns true for files and dirs.

func Kill

func Kill() error

Kill the running process by sending itself SIGTERM.

func MakeAbs

func MakeAbs(path string, root string) string

func MustReadFile

func MustReadFile(filePath string) []byte

func MustWriteFile

func MustWriteFile(filePath string, contents []byte, mode os.FileMode)

func PrintAllGoroutines

func PrintAllGoroutines()

func ProtocolAndAddress

func ProtocolAndAddress(listenAddr string) (string, string)

ProtocolAndAddress splits an address into the protocol and address components. For instance, "tcp://127.0.0.1:8080" will be split into "tcp" and "127.0.0.1:8080". If the address has no protocol prefix, the default is "tcp".

func ReadFile

func ReadFile(filePath string) ([]byte, error)

func TrapSignal

func TrapSignal(cb func())

TrapSignal catches the SIGTERM/SIGINT and executes cb function. After that it exits with code 0.

func WriteFile

func WriteFile(filePath string, contents []byte, mode os.FileMode) error

func WriteFileAtomic

func WriteFileAtomic(filename string, data []byte, perm os.FileMode) (err error)

WriteFileAtomic creates a temporary file with data and provided perm and swaps it atomically with filename if successful.

Types

type Process

type Process struct {
	Label     string
	WorkDir   string
	ExecPath  string
	Args      []string
	Pid       int
	StartTime time.Time
	EndTime   time.Time
	Cmd       *exec.Cmd        `json:"-"`
	ExitState *os.ProcessState `json:"-"`
	Stdin     io.Reader        `json:"-"`
	Stdout    io.WriteCloser   `json:"-"`
	Stderr    io.WriteCloser   `json:"-"`
	WaitCh    chan struct{}    `json:"-"`
}

func StartProcess

func StartProcess(label string, dir string, execPath string, args []string, stdin io.Reader, stdout, stderr io.WriteCloser) (*Process, error)

execPath: command name args: args to command. (should not include name)

func (*Process) StopProcess

func (proc *Process) StopProcess(kill bool) error

Jump to

Keyboard shortcuts

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