osutil

package
v2.0.0-...-7f6935a Latest Latest
Warning

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

Go to latest
Published: May 5, 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

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

func FilesystemFilename(filename string) (string, error)

func GetEnv

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

func GetFreeTcpPort

func GetFreeTcpPort() (int, error)

func HomeEnvVar

func HomeEnvVar() string

func IsCaseInsensitiveFileSystemCached

func IsCaseInsensitiveFileSystemCached() (bool, error)

func KillExecCmd

func KillExecCmd(cmd *exec.Cmd) error

func OpenBrowser

func OpenBrowser(url string) error

doesn't wait for the cmd to end

func OpenFilemanager

func OpenFilemanager(filename string) error

doesn't wait for the cmd to end

func RandomPort

func RandomPort(simpleSeed, min, max int) int

func RunCmdCombinedOutput

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

func RunCmdOutputs

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

func RunCmdStdoutAndStderrInErr

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

Adds stderr to err if it happens.

func SetEnv

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

func SetEnvs

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

func SetupExecCmdSysProcAttr

func SetupExecCmdSysProcAttr(cmd *exec.Cmd)

func ShellRunArgs

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

Types

type Cmd

type Cmd struct {
	*exec.Cmd

	PreOutputCallback func()

	NoEnsureStop bool
	// contains filtered or unexported fields
}

func NewCmd

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

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

func (*Cmd) Cancel

func (cmd *Cmd) Cancel()

can be called before a Start(), clears all possible resources

func (*Cmd) Run

func (cmd *Cmd) Run() error

func (*Cmd) SetupStdio

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

func (*Cmd) Start

func (cmd *Cmd) Start() error

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

func (*Cmd) Wait

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