cmd

package
v0.0.0-...-ec65a71 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chmod

func Chmod(ctx context.Context, path string, mode fs.FileMode, recursion ...bool) (err error)

func Chown

func Chown(ctx context.Context, path string, uid, gid uint32, recursion ...bool) (err error)

func Fork

func Fork(ctx context.Context, fOpts ForkOptions) (err error)

func ForkTag

func ForkTag() string

func IsForkTag

func IsForkTag(tag string) bool

func IsSignaled

func IsSignaled(err error) bool

func ParseGroupId

func ParseGroupId(nameOrId string) (g *user.Group, err error)

func ParseUserId

func ParseUserId(nameOrId string) (u *user.User, err error)

func Run

func Run(ctx context.Context, name string, args []string, opts RunOption) (err error)

func SetCredential

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

func SetNewNS

func SetNewNS(ctx context.Context, c *exec.Cmd)

func SetPdeathsig

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

func Setpgid

func Setpgid(c *exec.Cmd)

func SetupProcAttr

func SetupProcAttr(c *exec.Cmd, pdeathsig syscall.Signal, uid, gid uint32)

func User

func User(userNameOrId, groupNameOrId string) (uid, gid uint32, err error)

func WalkDir

func WalkDir(ctx context.Context, root string, fn func(path string, d fs.DirEntry) error) error

Types

type EnvSet

type EnvSet []string

EnvSet 环境变量集合,封装了一些对环境变量集合的操作

func (EnvSet) Clean

func (src EnvSet) Clean() EnvSet

Clean 清理无效的环境变量,重复的保留最后一个

func (EnvSet) Has

func (src EnvSet) Has(k string) bool

Has 判断是否已经包含某个键

func (EnvSet) Set

func (src EnvSet) Set(k, v string) (out EnvSet)

Set 设置环境变量,如果已经存在则先删除再追加

func (EnvSet) Unset

func (src EnvSet) Unset(k string) EnvSet

Unset 删除环境变量

type ForkOptions

type ForkOptions struct {
	Args []string
	Env  EnvSet
	Uid  uint32
	Gid  uint32
	Tag  string
}

type RunOption

type RunOption struct {
	Dir string
	Env EnvSet
	Tag string
	Log func(ctx context.Context, s string)
}

Jump to

Keyboard shortcuts

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