Documentation ¶
Overview ¶
Package `execx` provides utility functions that supplement the stdlib package `os/exec`.
`MustLookTool()` reliably locates external command line tools during program startup.
Example ¶
package main import ( "fmt" "os/exec" "github.com/nogproject/nog/backend/pkg/execx" ) var bash = execx.MustLookTool(execx.ToolSpec{ Program: "bash", CheckArgs: []string{"--version"}, CheckText: "GNU bash", }) func main() { out, _ := exec.Command(bash.Path, "-c", "echo hello").Output() fmt.Println(string(out)) }
Output: hello
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tool ¶
type Tool struct {
Path string
}
func MustLookTool ¶
`MustLookTool()` tries to run `s.Program` with `s.CheckArgs` and verifies that its output contains `s.CheckText`. If anything fails, `MustLookTool()` panics.
Click to show internal directories.
Click to hide internal directories.