Skip to content

Instantly share code, notes, and snippets.

@ionrock
Created January 11, 2018 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionrock/5fd9728b4581cc583888cdb48b9a1750 to your computer and use it in GitHub Desktop.
Save ionrock/5fd9728b4581cc583888cdb48b9a1750 to your computer and use it in GitHub Desktop.
type CreateCommand func() []string
type CommandExecutor struct {
CmdString string
Command CreateCommand
}
func (ce *CommandExecutor) defaultCommand() []string {
return []string{"/bin/bash", "-c", ce.CmdString}
}
func (ce *CommandExecutor) Run() ([]byte, error) {
if ce.Command == nil {
cd.Command = ce.defaultCommand
}
parts := ce.Command()
cmd := exec.Command(parts[0], parts[1:]...)
return cmd.Output()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment