Documentation
¶
Index ¶
- func CleanColor(str string) string
- func Exe() string
- type CP
- type Chdir
- type DirPushd
- type OSEnv
- func (oe *OSEnv) Append(key string, value string) error
- func (oe *OSEnv) Delete(key string) error
- func (oe *OSEnv) DeleteValue(key string, value string) error
- func (oe *OSEnv) Environ() []string
- func (oe *OSEnv) Get(key string) string
- func (oe *OSEnv) GetValues(key string) []string
- func (oe *OSEnv) Insert(key string, value string) error
- func (oe *OSEnv) MustAppend(key string, value string)
- func (oe *OSEnv) MustDelete(key string)
- func (oe *OSEnv) MustDeleteValue(key string, value string)
- func (oe *OSEnv) MustInsert(key string, value string)
- func (oe *OSEnv) MustSet(key string, value string)
- func (oe *OSEnv) Set(key string, value string) error
- func (oe *OSEnv) TryAppend(key string, value string)
- func (oe *OSEnv) TryDelete(key string)
- func (oe *OSEnv) TryDeleteValue(key string, value string)
- func (oe *OSEnv) TryInsert(key string, value string)
- func (oe *OSEnv) TrySet(key string, value string)
- func (oe *OSEnv) WithEnviron(es []string)
- type Tar
- type Wget
- type WorkerGroup
- type Zip
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanColor ¶ added in v0.0.5
Types ¶
type Chdir ¶ added in v0.0.3
type Chdir struct {
// contains filtered or unexported fields
}
Chdir 支持回退到之前目录的当前目录切换功能
func (*Chdir) MustGoBack ¶ added in v0.0.3
func (c *Chdir) MustGoBack()
MustGoBack 回到初始目录,若失败会 panic
type DirPushd ¶ added in v0.0.3
type DirPushd struct {
// contains filtered or unexported fields
}
DirPushd 类似 pushd、popd 命令的目录切换功能
type OSEnv ¶
type OSEnv struct {
// contains filtered or unexported fields
}
OSEnv 系统环境变量
func (*OSEnv) Append ¶
Append 设置环境变量,若有相同的 key,则将 value 补充在最后
PATH = /home/work/bin:/opt/bin Append("PATH","/home/root/bin") ---> PATH = /home/work/bin:/opt/bin:/home/root/bin
func (*OSEnv) Delete ¶
Delete 删除指定 key 的环境变量
PATH = /home/work/bin:/opt/bin Delete("PATH") Get("PATH") ---> ""
func (*OSEnv) DeleteValue ¶ added in v0.0.6
DeleteValue 删除环境变量中 key 的 指定的值
PATH = /home/work/bin:/opt/bin DeleteValue("PATH","/opt/bin") Get("PATH") ---> "/home/work/bin"
func (*OSEnv) Get ¶
Get 读取环境变量的值,若 key 不存在则返回空字符串
PATH = /home/work/bin:/opt/bin Get("PATH") ---> "/home/work/bin:/opt/bin"
func (*OSEnv) GetValues ¶ added in v0.0.6
GetValues 读取环境变量的值,并采用 ListSeparator 分割
PATH = /home/work/bin:/opt/bin GetValues("PATH") ---> ["/home/work/bin", "/opt/bin"]
func (*OSEnv) Insert ¶
Insert 设置环境变量,若有相同的 key,则将 value 插入到最前面
PATH = /home/work/bin:/opt/bin Insert("PATH","/home/root/bin") ---> PATH = /home/root/bin:/home/work/bin:/opt/bin
func (*OSEnv) MustAppend ¶ added in v0.0.6
MustAppend Append 的别名,若有错误会 panic
func (*OSEnv) MustDelete ¶ added in v0.0.6
MustDelete Delete 的别名,若有错误会 panic
func (*OSEnv) MustDeleteValue ¶ added in v0.0.6
MustDeleteValue DeleteValue 的别名,若有错误会 panic
func (*OSEnv) MustInsert ¶ added in v0.0.6
MustInsert Insert 的别名,若有错误会 panic
func (*OSEnv) Set ¶
Set 设置环境变量,若有相同的 key,则整体覆盖掉
PATH = /home/work/bin:/opt/bin Set("PATH","/home/root/bin") ---> PATH = /home/root/bin
func (*OSEnv) TryDeleteValue ¶ added in v0.0.6
TryDeleteValue DeleteValue 的别名,忽略错误
type Tar ¶
type Tar struct { // UnpackNextBefore 在 Unpack 时,解析到下一个 Header 后,实际 unpack 前的回调 UnpackNextBefore func(h *tar.Header) (skip bool, err error) // UnpackNextAfter 在 Unpack 时,解析到下一个 Header 后,实际 unpack 后的回调 UnpackNextAfter func(h *tar.Header, err error) error // UnCompress Unpack 时的解压缩方法,可选 // 默认为按照文件后缀自动选择: // 1.后缀为 .gz 和 .tgz 时选择 gzip UnCompress func(rd io.Reader) (io.Reader, error) // StripComponents Unpack 的时候,忽略掉前 N 层目录 StripComponents uint // MinSize 最小文件大小,>0 时有效 MinSize int64 // MaxSize 最小文件大小,>0 时有效 MaxSize int64 // IgnoreFailed 是否忽略异常 // 不会忽略 UnpackNextBefore 返回的 error IgnoreFailed bool }
Tar tape archive 工具,目前已经具备压缩文件
type Wget ¶
type Wget struct { // LogWriter 用于日志输出,可选 LogWriter io.Writer // Proxy 代理配置,可选,当为 nil 时会使用 http.ProxyFromEnvironment Proxy func(*http.Request) (*url.URL, error) // Timeout 整体超时 Timeout time.Duration // ConnectTimeout 连接超时,可选 ConnectTimeout time.Duration // InsecureSkipVerify 是否跳过 tls 证书校验,可选 InsecureSkipVerify bool }
Wget 提供类似 wget 的功能
type WorkerGroup ¶ added in v0.0.5
type WorkerGroup struct { // Max 最大并发度,可选,默认为 1 Max int // contains filtered or unexported fields }
func (*WorkerGroup) Run ¶ added in v0.0.5
func (wg *WorkerGroup) Run(fn func())
func (*WorkerGroup) Wait ¶ added in v0.0.5
func (wg *WorkerGroup) Wait()
type Zip ¶
type Zip struct { // UnpackNextBefore 在 Unpack 时,解析到下一个 Header 后,实际 unpack 前的回调 UnpackNextBefore func(f *zip.File) (skip bool, err error) // UnpackNextAfter 在 Unpack 时,解析到下一个 Header 后,实际 unpack 后的回调 UnpackNextAfter func(f *zip.File, err error) error // StripComponents Unpack 的时候,忽略掉前 N 层目录 StripComponents uint // MinSize 最小文件大小,>0 时有效 MinSize int64 // MaxSize 最小文件大小,>0 时有效 MaxSize int64 // IgnoreFailed 是否忽略异常 // 不会忽略 UnpackNextBefore 返回的 error IgnoreFailed bool }
Zip 解压缩 .zip 文件
Source Files
¶
Click to show internal directories.
Click to hide internal directories.