cmdutil

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 17 Imported by: 1

README

Command Utilities

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CP

type CP struct {
}

CP todo

func (*CP) Copy

func (cp *CP) Copy(dst string, srcs ...string) error

type Chdir added in v0.0.3

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

func MustChdir added in v0.0.3

func MustChdir(to string) *Chdir

func NewChdir added in v0.0.3

func NewChdir(to string) (*Chdir, error)

func (*Chdir) GoBack added in v0.0.3

func (c *Chdir) GoBack() error

func (*Chdir) MustGoBack added in v0.0.3

func (c *Chdir) MustGoBack()

type DirPushd added in v0.0.3

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

func (*DirPushd) MustPopd added in v0.0.3

func (dp *DirPushd) MustPopd()

func (*DirPushd) MustPushd added in v0.0.3

func (dp *DirPushd) MustPushd(dir string)

func (*DirPushd) Popd added in v0.0.3

func (dp *DirPushd) Popd() error

func (*DirPushd) Pushd added in v0.0.3

func (dp *DirPushd) Pushd(dir string) error

type OSEnv

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

func (*OSEnv) Append

func (oe *OSEnv) Append(key string, value string) error

func (*OSEnv) Delete

func (oe *OSEnv) Delete(key string) error

func (*OSEnv) Environ

func (oe *OSEnv) Environ() []string

func (*OSEnv) Get

func (oe *OSEnv) Get(key string) string

func (*OSEnv) Insert

func (oe *OSEnv) Insert(key string, value string) error

func (*OSEnv) Set

func (oe *OSEnv) Set(key string, value string) error

func (*OSEnv) WithEnviron

func (oe *OSEnv) WithEnviron(es []string)

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 工具,目前已经具备压缩文件

func (*Tar) Unpack

func (tr *Tar) Unpack(archiveFile string, targetDir string) error

Unpack 解压缩文件到指定目录

func (*Tar) UnpackFromReader

func (tr *Tar) UnpackFromReader(trd *tar.Reader, targetDir string) error

UnpackFromReader 从 tar.Reader 解压数据

type Wget

type Wget struct {
	LogWriter io.Writer

	Proxy func(*http.Request) (*url.URL, error)

	// Timeout 整体超时
	Timeout time.Duration

	// ConnectTimeout 连接超时
	ConnectTimeout time.Duration

	InsecureSkipVerify bool
}

Wget 提供类似 wget 的功能

func (*Wget) Download

func (w *Wget) Download(src string, dst string) error

Download 从 src 这个地址下载到 dst 这个文件

func (*Wget) DownloadToWriter

func (w *Wget) DownloadToWriter(src string, dst io.Writer) error

DownloadToWriter 下载数据并写入指定的 writer

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 文件

func (*Zip) Unpack

func (zp *Zip) Unpack(archiveFile string, targetDir string) error

Unpack 解压缩文件到指定目录

func (*Zip) UnpackFromReader

func (zp *Zip) UnpackFromReader(zrd *zip.Reader, targetDir string) error

UnpackFromReader 解压 zip.Reader

Directories

Path Synopsis
_example
tar
zip
Package gosdk 提供查找本机 go sdk 路径的功能 会从环境变量 $PATH 和目录 ~/sdk/ 查找
Package gosdk 提供查找本机 go sdk 路径的功能 会从环境变量 $PATH 和目录 ~/sdk/ 查找

Jump to

Keyboard shortcuts

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