osutil

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 17 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 FsCaseFilename added in v1.3.3

func FsCaseFilename(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 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 OpenExternal added in v1.3.7

func OpenExternal(name 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 OpenTerminal added in v1.3.1

func OpenTerminal(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 RunCmd added in v1.3.7

func RunCmd(ctx context.Context, dir string, args ...string) ([]byte, error)

func RunCmdI added in v1.3.3

func RunCmdI(ci CmdI) error

func RunCmdICombineStderrErr added in v1.3.7

func RunCmdICombineStderrErr(c CmdI) ([]byte, error)

func RunCmdICombineStdoutStderr added in v1.3.7

func RunCmdICombineStdoutStderr(c CmdI) ([]byte, error)

func RunCmdIOutputs added in v1.3.7

func RunCmdIOutputs(c CmdI) (sout []byte, serr []byte, _ error)

func RunCmdStdin added in v1.3.7

func RunCmdStdin(ctx context.Context, dir string, rd io.Reader, args ...string) ([]byte, error)

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

func UnquoteEnvValues added in v1.3.1

func UnquoteEnvValues(env []string) []string

Types

type BasicCmd added in v1.3.3

type BasicCmd struct {
	// contains filtered or unexported fields
}

func NewBasicCmd added in v1.3.3

func NewBasicCmd(cmd *exec.Cmd) *BasicCmd

func (*BasicCmd) Cmd added in v1.3.3

func (c *BasicCmd) Cmd() *exec.Cmd

func (*BasicCmd) Start added in v1.3.3

func (c *BasicCmd) Start() error

func (*BasicCmd) Wait added in v1.3.3

func (c *BasicCmd) Wait() error

type CmdI added in v1.3.3

type CmdI interface {
	Cmd() *exec.Cmd
	Start() error
	Wait() error
}

func NewCmdI added in v1.3.3

func NewCmdI(cmd *exec.Cmd) CmdI

func NewCmdI2 added in v1.3.7

func NewCmdI2(ctx context.Context, args ...string) CmdI

func NewCmdI3 added in v1.3.7

func NewCmdI3(ctx context.Context, cmd *exec.Cmd) CmdI

type CtxCmd added in v1.3.7

type CtxCmd struct {
	CmdI
	// contains filtered or unexported fields
}

func NewCtxCmd added in v1.3.7

func NewCtxCmd(ctx context.Context, cmdi CmdI) *CtxCmd

func (*CtxCmd) Start added in v1.3.7

func (c *CtxCmd) Start() error

func (*CtxCmd) Wait added in v1.3.7

func (c *CtxCmd) Wait() error

type NoHangPipeCmd added in v1.3.7

type NoHangPipeCmd struct {
	CmdI
	// contains filtered or unexported fields
}

func NewNoHangPipeCmd added in v1.3.7

func NewNoHangPipeCmd(cmdi CmdI, doIn, doOut, doErr bool) *NoHangPipeCmd

func (*NoHangPipeCmd) CloseStdin added in v1.3.7

func (c *NoHangPipeCmd) CloseStdin() error

some commands will not exit unless the stdin is closed, allow access

func (*NoHangPipeCmd) Start added in v1.3.7

func (c *NoHangPipeCmd) Start() error

type PausedWritersCmd added in v1.3.7

type PausedWritersCmd struct {
	CmdI
	// contains filtered or unexported fields
}

ex: usefull to print something before any cmd output is printed

func NewPausedWritersCmd added in v1.3.7

func NewPausedWritersCmd(cmdi CmdI, cb func(CmdI)) *PausedWritersCmd

func (*PausedWritersCmd) Start added in v1.3.7

func (c *PausedWritersCmd) Start() error

func (*PausedWritersCmd) Wait added in v1.3.7

func (c *PausedWritersCmd) Wait() error

type ShellCmd added in v1.3.3

type ShellCmd struct {
	CmdI
}

func NewShellCmd added in v1.3.3

func NewShellCmd(cmdi CmdI) *ShellCmd

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