utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: GPL-3.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressZip

func CompressZip(files []*os.File, dest string) error

CompressZip Compress files to zip files File array, which can be files or folders under different dirs dest Compressed file storage address

func CreateCar

func CreateCar(
	ctx context.Context,
	inputDirectory string,
	outputFile string,

	version int,
) (string, error)

func DeCompressZip

func DeCompressZip(zipFile, dest string) error

DeCompressZip Zip unzip

func DefaultConfigDir

func DefaultConfigDir() string

func GetFilenameWithSuffixAndFilenameOnly

func GetFilenameWithSuffixAndFilenameOnly(path string) (fileName string, fileNameWithSuffix string)

GetFilenameWithSuffixAndFilenameOnly 获取带后置的文件名和不带后缀的文件名

func GetFiles

func GetFiles(workdir string, fuzzyPath []string, pathList []string) []string

GetFiles 获取文件路径集合 workdir 基础路径 fuzzyPath 要赛选的路径 pathList 查找到的路径对象

func GetRedundantPath

func GetRedundantPath(shortPath string, longPath string) (err error, path string)

GetRedundantPath 获取多余的路径 longPath相对于shortPath的 /a/b/ /a/b/c/d.txt return c/d.txt

func GetSameFileNameFiles

func GetSameFileNameFiles(workdir string, fileName string, pathList []string) []string

GetSameFileNameFiles 获取路径下的所有相同文件文件名的文件 workdir 基础路径 fileName 要赛选的路径 pathList 查找到的路径对象

func GetSuffixFiles

func GetSuffixFiles(workdir string, suffixName string, pathList []string) []string

GetSuffixFiles 获取路径下的所有相同后缀文件 workdir 基础路径 suffixName 要赛选的路径 pathList 查找到的路径对象

func GetUIDAndGID

func GetUIDAndGID() (string, string, error)

func RandSeq

func RandSeq(n int) string

func ReplaceWithParam

func ReplaceWithParam(content string, paramMap map[string]string) string

ReplaceWithParam 参数替换

func SlicePage

func SlicePage(page, pageSize, nums int) (int, int, int, int)

SlicePage paging return:page,pageSize,start,end

Types

type Cmd

type Cmd struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(ctx context.Context, command string, args ...string) *Cmd

NewCommand is like exec.CommandContext but ensures that subprocesses are killed when the context times out, not just the top level process.

func (*Cmd) Run

func (c *Cmd) Run() error

func (*Cmd) Start

func (c *Cmd) Start() error

type Stack

type Stack[T interface{}] struct {
	// contains filtered or unexported fields
}

Stack 堆栈

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

IsEmpty 判断堆栈是否为空

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (T, error)

Pop 出栈

func (*Stack[T]) Push

func (s *Stack[T]) Push(value T)

Push 入栈

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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