sys

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGKILL = syscall.SIGKILL
	SIGINT  = syscall.SIGINT
)

Variables

View Source
var B32 = base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567").WithPadding(base32.NoPadding)

Functions

func Call

func Call(ctx context.Context, callers ...Caller) (err error)

顺序执行

func Cat

func Cat(path string) string

cat 以utf8编码读取文件文本内容

func FileNotExist

func FileNotExist(path string) bool

func IOCopy added in v0.0.2

func IOCopy(ctx context.Context, w io.Writer, r io.Reader) (err error)

func IOR added in v0.0.2

func IOR(ctx context.Context, r io.Reader) io.Reader

func IORE added in v0.0.2

func IORE(r io.Reader, err error) io.ReadCloser

func IOW added in v0.0.2

func IOW(ctx context.Context, w io.Writer) io.Writer

func IOWriteFile added in v0.0.2

func IOWriteFile(ctx context.Context, src io.Reader, dstPath string, perm fs.FileMode) (err error)

func IsDir

func IsDir(path string) bool

func IsDirEmpty

func IsDirEmpty(path string) bool

func IsFile

func IsFile(path string) bool

func IsForkTag added in v0.0.3

func IsForkTag(tag string) bool

func IsSignaled added in v0.0.9

func IsSignaled(err error) bool

func IsSubPath

func IsSubPath(basepath, targpath string) bool
func IsSymlink(path string) bool

func MessageRecive added in v0.0.8

func MessageRecive(ctx context.Context, handleMessage func(ctx context.Context, msg string)) io.WriteCloser

func ParallelCall

func ParallelCall(ctx context.Context, callers ...Caller) error

并行执行

func RandText

func RandText(n int) (s string)

randText 生成一个指定长度的随机字符串。

func ReadDirNames

func ReadDirNames(path string, n int) (files []string, err error)

func ReadDirs

func ReadDirs(path string, n int) (files []fs.DirEntry, err error)

func RealPath

func RealPath(path string) (string, error)

func SetChroot

func SetChroot(c *exec.Cmd, root string)

func SetCredential

func SetCredential(c *exec.Cmd, uid, gid uint32)

func SetNewNS

func SetNewNS(c *exec.Cmd)

func SetPdeathsig

func SetPdeathsig(c *exec.Cmd, sig syscall.Signal)

func SkipErrCall added in v0.0.6

func SkipErrCall(ctx context.Context, callers ...Caller)

顺序执行

func Symlink(srcPath, dstPath string) func(ctx context.Context) (err error)

Symlink 建立软链接

func TarExtract added in v0.0.2

func TarExtract(ctx context.Context, src io.Reader, walk TarWalkFunc, decoder ...TarDecoder) (err error)

func UserLookup

func UserLookup(userOrId, groupOrId string) (uid, gid uint32, err error)

Types

type Caller

type Caller func(ctx context.Context) (err error)

func Bind

func Bind(srcPath, rootDir string, recursive ...bool) Caller

func Chdir

func Chdir(target string) Caller

func Chmod

func Chmod(path string, perm fs.FileMode, recursive ...bool) Caller

func Chown

func Chown(path string, uid, gid uint32, recursive ...bool) Caller

func Chroot

func Chroot(target string) Caller

func Chtimes added in v0.0.5

func Chtimes(name string, atime, mtime, ctime time.Time) Caller

func FileWrite

func FileWrite[T ~string | ~[]byte](path string, data T, perm os.FileMode, overwrite ...bool) Caller

fileWrite 写入文件,存在则跳过

func FileWriteCopy

func FileWriteCopy[T ~string | ~[]byte](writeTo, copyTo string, data T, perm os.FileMode) Caller

fileWriteCopy 先写入文件到 writeTo,存在则跳过写入,再复制到 copyTo,存在则跳过

func Fork added in v0.0.3

func Fork(name string, args []string, env []string, tag string) Caller

func Mkdir

func Mkdir(path string, perm fs.FileMode, recursives ...bool) Caller

func Mkdirs

func Mkdirs(path string) Caller

func Mount

func Mount(device, target, mType, options string, force ...bool) Caller

func Unmount

func Unmount(target string, recursives ...bool) Caller

func (Caller) Call

func (f Caller) Call(ctx context.Context) (err error)

func (Caller) Wrap

func (f Caller) Wrap(ctx context.Context) func() error

type Env

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

func NewEnv

func NewEnv() *Env

func (*Env) Append

func (e *Env) Append(envs ...string) *Env

func (*Env) AppendOS

func (e *Env) AppendOS() *Env

func (*Env) Each

func (e *Env) Each(walkFn func(k, v string))

func (*Env) Environ

func (e *Env) Environ() (environs []string)

func (Env) Init

func (e Env) Init() *Env

func (*Env) Merge

func (e *Env) Merge(another *Env)

func (*Env) Set

func (e *Env) Set(k, v string) *Env

func (*Env) SetOptional

func (e *Env) SetOptional(k, v string) *Env

type TarDecoder added in v0.0.2

type TarDecoder func(io.Reader) (io.ReadCloser, error)

func (TarDecoder) Decode added in v0.0.2

func (d TarDecoder) Decode(r io.Reader) io.ReadCloser

type TarWalkFunc added in v0.0.2

type TarWalkFunc func(ctx context.Context, r io.Reader, h *tar.Header) (err error)

func (TarWalkFunc) Read added in v0.0.2

func (w TarWalkFunc) Read(ctx context.Context, r io.Reader, h *tar.Header) (err error)

Jump to

Keyboard shortcuts

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