core

package module
v0.0.0-...-ede170f Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2017 License: MIT Imports: 16 Imported by: 4

README

core

Useful functions for Golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseName

func BaseName(path string) string

BaseName is get file name without extension.

func CompileStrs

func CompileStrs(regStrs []string) (*regexp.Regexp, error)

CompileStrs is regexp strings compile to *regexp.Regexp.

func FailOnError

func FailOnError(err error)

FailOnError is fail if err occured.

func GetCmdPath

func GetCmdPath(cmd string) (string, error)

GetCmdPath returns cmd abs path.

func GetGlobArgs

func GetGlobArgs(args []string) ([]string, error)

GetGlobArgs return glob files.

func IsMatchStrs

func IsMatchStrs(str string, regStrs []string) (bool, error)

IsMatchStrs is whether str match or not.

func PP

func PP(a ...interface{}) (int, error)

PP is wrapper of pp Println.

func PPf

func PPf(format string, a ...interface{}) (int, error)

PPf is wrapper of pp Printf.

func ReadToBuf

func ReadToBuf(scanner *bufio.Scanner) (*bytes.Buffer, error)

ReadToBuf is scan and store buffer.

func ScanPrintStderr

func ScanPrintStderr(scanner *bufio.Scanner, print bool)

ScanPrintStderr is scan and print to stderr.

func ScanPrintStdout

func ScanPrintStdout(scanner *bufio.Scanner, print bool)

ScanPrintStdout is scan and print to stdout.

func ScanWrite

func ScanWrite(scanner *bufio.Scanner, writer io.Writer, print bool)

ScanWrite is scan and write to io.Writer.

func SurroundWord

func SurroundWord(w string, r rune) string

SurroundWord surround word.

Types

type Cmd

type Cmd struct {
	Cmd     *exec.Cmd
	CmdLine string

	Stdin  bytes.Buffer
	Stdout bytes.Buffer
	Stderr bytes.Buffer

	ExitError error
	ExitCode  int

	StdinEnc  *encoding.Decoder
	StdoutEnc *encoding.Decoder
	StderrEnc *encoding.Decoder

	StdoutPrint bool
	StderrPrint bool

	Wg sync.WaitGroup
	// contains filtered or unexported fields
}

Cmd is command infomation.

func NewCmd

func NewCmd(cmdLine string) (*Cmd, error)

NewCmd create Cmd struct pointer.

func (*Cmd) CmdRun

func (c *Cmd) CmdRun() error

CmdRun run command.

func (*Cmd) CmdStart

func (c *Cmd) CmdStart() error

CmdStart start cmdFile.

func (*Cmd) CmdWait

func (c *Cmd) CmdWait()

CmdWait wait command end.

func (*Cmd) GetExitCode

func (c *Cmd) GetExitCode()

GetExitCode set command ExitCode.

func (*Cmd) StderrPipe

func (c *Cmd) StderrPipe() (io.ReadCloser, error)

StderrPipe return exec.StderrPipe.

func (*Cmd) StderrScanner

func (c *Cmd) StderrScanner() (*bufio.Scanner, error)

StderrScanner make bufio.Scanner.

func (*Cmd) StdinPipe

func (c *Cmd) StdinPipe() (io.WriteCloser, error)

StdinPipe return exec.StdinPipe.

func (*Cmd) StdoutPipe

func (c *Cmd) StdoutPipe() (io.ReadCloser, error)

StdoutPipe return exec.StdoutPipe.

func (*Cmd) StdoutScanner

func (c *Cmd) StdoutScanner() (*bufio.Scanner, error)

StdoutScanner make bufio.Scanner.

Jump to

Keyboard shortcuts

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