osutil

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const EscapeRune = '\\'

Variables

This section is empty.

Functions

func ExecName

func ExecName(name string) string

func FilepathClean added in v1.1.0

func FilepathClean(s string) string

func FilepathHasDirPrefix

func FilepathHasDirPrefix(s, prefix string) bool

func FilepathSplitAt

func FilepathSplitAt(s string, n int) string

Result does not start with separator.

func FilesystemFilename added in v1.1.0

func FilesystemFilename(filename string) (string, error)

func GetEnv added in v1.1.0

func GetEnv(env []string, key string) string

func GetFreeTcpPort added in v1.1.0

func GetFreeTcpPort() (int, error)

func HomeEnvVar

func HomeEnvVar() string

func IsCaseInsensitiveFileSystemCached added in v1.1.0

func IsCaseInsensitiveFileSystemCached() (bool, error)

func KillExecCmd

func KillExecCmd(cmd *exec.Cmd) error

func OpenBrowser added in v1.1.0

func OpenBrowser(url string) error

doesn't wait for the cmd to end

func OpenFilemanager added in v1.1.0

func OpenFilemanager(filename string) error

doesn't wait for the cmd to end

func RandomPort added in v1.1.0

func RandomPort(simpleSeed, min, max int) int

func RunCmdCombinedOutput added in v1.1.0

func RunCmdCombinedOutput(cmd *Cmd, rd io.Reader) ([]byte, error)

func RunCmdOutputs added in v1.1.0

func RunCmdOutputs(cmd *Cmd, rd io.Reader) (sout []byte, serr []byte, _ error)

func RunCmdStdoutAndStderrInErr added in v1.1.0

func RunCmdStdoutAndStderrInErr(cmd *Cmd, rd io.Reader) ([]byte, error)

Adds stderr to err if it happens.

func SetEnv added in v1.1.0

func SetEnv(env []string, key, value string) []string

func SetEnvs added in v1.1.0

func SetEnvs(env []string, addEnv []string) []string

func SetupExecCmdSysProcAttr

func SetupExecCmdSysProcAttr(cmd *exec.Cmd)

func ShellRunArgs

func ShellRunArgs(args ...string) []string

Types

type Cmd added in v1.1.0

type Cmd struct {
	*exec.Cmd

	PreOutputCallback func()

	NoEnsureStop bool
	// contains filtered or unexported fields
}

func NewCmd added in v1.1.0

func NewCmd(ctx context.Context, args ...string) *Cmd

If Start() is not called, Cancel() must be called to clear resources.

func (*Cmd) Cancel added in v1.1.0

func (cmd *Cmd) Cancel()

func (*Cmd) Run added in v1.1.0

func (cmd *Cmd) Run() error

func (*Cmd) SetupStdio added in v1.1.0

func (cmd *Cmd) SetupStdio(ir io.Reader, ow, ew io.Writer) error

func (*Cmd) Start added in v1.1.0

func (cmd *Cmd) Start() error

If Start() returns no error, Wait() must be called to clear resources.

func (*Cmd) Wait added in v1.1.0

func (cmd *Cmd) Wait() error

type TmpFiles

type TmpFiles struct {
	Dir string
}

func NewTmpFiles

func NewTmpFiles(prefix string) *TmpFiles

func (*TmpFiles) MkdirInTmp

func (tf *TmpFiles) MkdirInTmp(path string) (string, error)

func (*TmpFiles) MkdirInTmpOrPanic

func (tf *TmpFiles) MkdirInTmpOrPanic(path string) string

Returns the filename

func (*TmpFiles) RemoveAll

func (tf *TmpFiles) RemoveAll() error

func (*TmpFiles) WriteFileInTmp

func (tf *TmpFiles) WriteFileInTmp(path string, src []byte) (string, error)

func (*TmpFiles) WriteFileInTmp2OrPanic

func (tf *TmpFiles) WriteFileInTmp2OrPanic(path string, src string) string

Returns the filename

func (*TmpFiles) WriteFileInTmpOrPanic

func (tf *TmpFiles) WriteFileInTmpOrPanic(path string, src []byte) string

Returns the filename

Jump to

Keyboard shortcuts

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