system

package
v0.0.0-...-21311fb Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAll

func CopyAll(src, dst string) (fileCount uint, err error)

Recursively copy dst must always be a directory src may be either a dir or a file

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies contents of src to dst atomically using SharedReadWriteMask as permissions.

func CopyFileWithPerms

func CopyFileWithPerms(src, dst string, perm os.FileMode) error

CopyFileWithPerms copies the contents from src to dst atomically. If dst does not exist, CopyFile creates it with permissions perm. If the copy fails, CopyFile aborts and dst is preserved. Adopted with modifications from https://go-review.googlesource.com/#/c/1591/9/src/io/ioutil/ioutil.go

func Exec

func Exec(cmd *exec.Cmd, out io.Writer, setters ...CommandOptionSetter) error

ExecL executes the specified command and outputs its Stdout/Stderr into the specified writer `out`. Accepts configuration as a series of CommandOptionSetters

func ExecL

func ExecL(cmd *exec.Cmd, out io.Writer, logger log.FieldLogger, setters ...CommandOptionSetter) error

ExecL executes the specified command and outputs its Stdout/Stderr into the specified writer `out`, using `logger` for logging. Accepts configuration as a series of CommandOptionSetters

func ExecWithInput

func ExecWithInput(cmd *exec.Cmd, input string, out io.Writer, setters ...CommandOptionSetter) error

ExecWithInput executes the specified command and outputs its Stdout/Stderr into the specified writer `out`. Uses `input` to provide command with Stdin input Accepts configuration as a series of CommandOptionSetters

func RemoveAll

func RemoveAll(dir string) error

RemoveAll removes the specified directory including sub-directories

Types

type CommandOptionSetter

type CommandOptionSetter func(cmd *exec.Cmd)

CommandOptionSetter defines an interface to configure child process before execution

func Dir

func Dir(dir string) CommandOptionSetter

Dir sets working directory for the child process

func SetEnv

func SetEnv(envs ...string) CommandOptionSetter

SetEnv passes specified environment variables to the child process

Jump to

Keyboard shortcuts

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