{"modulePath":"github.com/codecrafters-io/tester-utils","version":"v0.4.18","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package executable\n\n## Variables\n\n```go\nvar ErrMemoryLimitExceeded = errors.New(\"process exceeded memory limit\")\n```\nErrMemoryLimitExceeded is returned when a process exceeds its memory limit\n\n## Functions\n\n```go\nfunc GetMemoryLimitInBytes() int64\n```\n\n```go\nfunc ResolveAbsolutePath(path string) (absolutePath string, err error)\n```\nResolveAbsolutePath resolves the path according the following rules: 1. If executable is not found ('path' is neither in $PATH, nor found at the path specified) -\u003e Error is returned 2. If the 'path' contains slash, its absolute path is returned 3. If the 'path' does not contains a slash, it is searched for in PATH and its absolute path\n\n## Types\n\n```go\ntype Executable struct {\n\t// Path is the path to the executable.\n\tPath string\n\n\t// TimeoutInMilliseconds is the maximum time the process can run.\n\tTimeoutInMilliseconds int\n\n\t// MemoryLimitInBytes sets the maximum memory the process can use (Linux only).\n\t// If exceeded, the process will be killed and an error will be returned.\n\t// Defaults to 2GB. Set to 0 to disable memory limiting.\n\tMemoryLimitInBytes int64\n\n\t// ShouldUsePtyOutputStreams controls whether the executable's standard streams should be set to PTY instead of pipes.\n\tShouldUsePtyOutputStreams bool\n\n\t// WorkingDir can be set before calling Start or Run to customize the working directory of the executable.\n\tWorkingDir string\n\n\t// Process is the os.Process object for the executable.\n\t// TODO: See if this actually needs to be exported?\n\tProcess *os.Process\n\t// contains filtered or unexported fields\n}\n```\nExecutable represents a program that can be executed\n\n```go\nfunc NewExecutable(path string) *Executable\n```\nNewExecutable returns an Executable\n\n```go\nfunc NewVerboseExecutable(path string, loggerFunc func(string)) *Executable\n```\nNewVerboseExecutable returns an Executable struct with a logger configured\n\n```go\nfunc (e *Executable) Clone() *Executable\n```\n\n```go\nfunc (e *Executable) HasExited() bool\n```\n\n```go\nfunc (e *Executable) Kill() error\n```\nKill terminates the program\n\n```go\nfunc (e *Executable) Run(args ...string) (ExecutableResult, error)\n```\nRun starts the specified command, waits for it to complete and returns the result.\n\n```go\nfunc (e *Executable) RunWithStdin(stdin []byte, args ...string) (ExecutableResult, error)\n```\nRunWithStdin starts the specified command, sends input, waits for it to complete and returns the result.\n\n```go\nfunc (e *Executable) Start(args ...string) error\n```\nStart starts the specified command but does not wait for it to complete.\n\n```go\nfunc (e *Executable) Wait() (ExecutableResult, error)\n```\nWait waits for the program to finish and returns the result.\n\n```go\ntype ExecutableResult struct {\n\tStdout   []byte\n\tStderr   []byte\n\tExitCode int\n}\n```\nExecutableResult holds the result of an executable run\n\n","path":"github.com/codecrafters-io/tester-utils/executable","name":"executable","synopsis":"","isRedistributable":true}
