io

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: Apache-2.0 Imports: 12 Imported by: 61

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRandomLenFile

func CreateRandomLenFile(maxLen int, filesDir string, prefix string) string

func RunCmd added in v1.0.3

func RunCmd(config CmdConfig) error

Runs an external process and prints its output to stdout / stderr.

func RunCmdOutput added in v1.0.3

func RunCmdOutput(config CmdConfig) (string, error)

Executes an external process and returns its output. If the returned output is not needed, use the RunCmd function instead , for better performance.

func RunCmdWithOutputParser added in v1.0.3

func RunCmdWithOutputParser(config CmdConfig, prompt bool, regExpStruct ...*CmdOutputPattern) (stdOut string, errorOut string, exitOk bool, err error)

Executes the command and captures the output. Analyze each line to match the provided regex. Returns the complete stdout output of the command.

Types

type CmdConfig added in v1.0.3

type CmdConfig interface {
	GetCmd() *exec.Cmd
	GetEnv() map[string]string
	GetStdWriter() io.WriteCloser
	GetErrWriter() io.WriteCloser
}

type CmdOutputPattern added in v1.0.3

type CmdOutputPattern struct {
	RegExp         *regexp.Regexp
	MatchedResults []string
	Line           string
	ExecFunc       func(pattern *CmdOutputPattern) (string, error)
}

RegExp - The regexp that the line will be searched upon. MatchedResults - The slice result that was found by the regex Line - The output line from the external process ExecFunc - The function to execute

type RandFile

type RandFile struct {
	*os.File
	Info os.FileInfo
}

func CreateRandFile

func CreateRandFile(path string, len int) (*RandFile, error)

Jump to

Keyboard shortcuts

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