Documentation ¶
Index ¶
- Variables
- func ConsumeOutAndError(outPipe, errPipe io.ReadCloser, ctx context.Context, ...)
- func FindParameterAfterFlag(got *string, args []string, flag string) bool
- func GetAppProgramPath(appName string) string
- func GetChildrenForPID(parentPID int64) []int64
- func GetOpenFileCount() int
- func GetPIDsForAppName(app string, excludeZombies bool) []int64
- func GetRunningProcessUserName() (string, error)
- func MakeCommand(command string, ctx context.Context, start bool, inPipe *io.WriteCloser, ...) (cmd *exec.Cmd, outPipe, errPipe io.ReadCloser, err error)
- func MemoryBytesUsedByProcess(processID int64) int64
- func OnDarwin() bool
- func OnLinux() bool
- func OnThreadExecutor(c *chan func(), rest func()) chan func()
- func PoolWorkOnItems[T any](all []T, poolSize int, do func(t *T))
- func PopProcess(p *proc)
- func PushProcess(timeoutSecs float64, info string) *proc
- func RepeatLogProcessUse()
- func RepeatPrintInOutRequests()
- func RestartSelf() error
- func RunAndWaitForFuncInMainThread(f func())
- func RunApp(appName string, ctx context.Context, args ...any) (cmd *exec.Cmd, outPipe, errPipe io.ReadCloser, inPipe io.WriteCloser, ...)
- func RunAppleScript(command string, timeoutSecs float64) (string, error)
- func RunBashCommand(command string, timeoutSecs float64) (string, error)
- func RunCommand(command string, timeoutSecs float64, args ...any) (string, error)
- func RunCommandWithSSHPass(cmd string, passwords []string, options *SSHPassOptions) error
- func RunCommandWithSudo(command, password string, args ...any) (string, error)
- func RunFuncInMainThread(f func())
- func RunFuncUntilContextDone(ctx context.Context, do func()) (completed bool)
- func RunFuncUntilTimeoutSecs(secs float64, do func()) (completed bool)
- func SetNumberOfOpenFiles(n int)
- func StartMainThreadExecutor(rest func())
- func TerminateAppsByName(name string, force, children bool) (oerr error)
- func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool
- type Installer
- func (i *Installer) BinPath(isFile bool, parts ...string) string
- func (i *Installer) ID() string
- func (i *Installer) InstallProgramWithLauncher(args []string, copyBinary bool) error
- func (i *Installer) OptPath(isFile bool, parts ...string) string
- func (i *Installer) VarPath(isFile bool, parts ...string) string
- type OnceWait
- type SSHPassOptions
Constants ¶
This section is empty.
Variables ¶
var (
MainThreadExeCh chan func()
)
var SSHPassDefaultOptions = &SSHPassOptions{ ExpectedPrompt: "password:", ExpectedFailure: "denied", Timeout: time.Second * 10, AutoConfirmHostAuthenticity: true, Shell: "", }
Functions ¶
func ConsumeOutAndError ¶
func FindParameterAfterFlag ¶
func GetAppProgramPath ¶
func GetChildrenForPID ¶
func GetOpenFileCount ¶
func GetOpenFileCount() int
func GetPIDsForAppName ¶
GetPIDsForAppName returns the pid for all processes with executable name *app*. *excludeZombies* checks if it has a ps Z state and doesn't add it to list then. This can take quite a long time.
func MakeCommand ¶
func OnThreadExecutor ¶
func OnThreadExecutor(c *chan func(), rest func()) chan func()
func PoolWorkOnItems ¶
PoolWorkOnItems runs jobs with do(), processing all in goroutines, But up to max poolSize at a time.
func PopProcess ¶
func PopProcess(p *proc)
func PushProcess ¶
func RepeatLogProcessUse ¶
func RepeatLogProcessUse()
func RepeatPrintInOutRequests ¶
func RepeatPrintInOutRequests()
func RestartSelf ¶
func RestartSelf() error
func RunAndWaitForFuncInMainThread ¶
func RunAndWaitForFuncInMainThread(f func())
func RunApp ¶
func RunApp(appName string, ctx context.Context, args ...any) (cmd *exec.Cmd, outPipe, errPipe io.ReadCloser, inPipe io.WriteCloser, err error)
RunApp runs appName in Applications (for mac), and returns the exec.Cmd and out/err readers and in writer. If ctx is nil, the command it run without a context. using exec.Command in MakeCommand.
func RunCommandWithSSHPass ¶
func RunCommandWithSSHPass(cmd string, passwords []string, options *SSHPassOptions) error
Run attempts to run the provided command and insert the given passwords one by one when prompted.
func RunCommandWithSudo ¶
RunCommandWithSudo runs command with args on the shell, using sudo and stdin to 'type' password to sudo.
func RunFuncInMainThread ¶
func RunFuncInMainThread(f func())
func RunFuncUntilContextDone ¶
RunFuncUntilContextDone waits for do() to finish or the context to be done If it finishes it returns completed = true, otherwise the goroutine continues, but it returns with false.
func RunFuncUntilTimeoutSecs ¶
RunFuncUntilTimeoutSecs uses RunFuncUntilContextDone to wait secs for a function to finish, or returns while it's still running in a goroutine.
func SetNumberOfOpenFiles ¶
func SetNumberOfOpenFiles(n int)
func StartMainThreadExecutor ¶
func StartMainThreadExecutor(rest func())
func TerminateAppsByName ¶
Types ¶
type Installer ¶
type Installer struct { Company string ProductName string Domain string UserName string // username to set owner of file/dirs }
func (*Installer) InstallProgramWithLauncher ¶
type OnceWait ¶
type OnceWait struct {
// contains filtered or unexported fields
}
OnceWait is something you call Wait() on and it waits until Done() is called on it. Once. Use to wait for some global data to be inited for example. TODO: Check if a semaphore could be used.
type SSHPassOptions ¶
type SSHPassOptions struct { ExpectedPrompt string // ExpectedPrompt is the string to treat as the password prompt e.g. "Password: " ExpectedFailure string // ExpectedFailure is the string to treat as an indication of failure e.g. "Incorrect password" Timeout time.Duration // Timeout is the duration to wait for a prompt/failure before giving up AutoConfirmHostAuthenticity bool // AutoConfirmHostAuthenticity will type 'yes' on host authenticity confirmations when set Shell string // Shell is a path to the shell to use e.g. /bin/bash - leave blank to use user shell }