snake

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

README

snake

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type FileOperate

type FileOperate interface {
	Get() *os.File
	String() *SnakeString
	Byte() []byte
	Close() error // 关闭文件链接
}

FileOperate ...

func File

func File(f *os.File) FileOperate

File 初始化...

type FileSystem

type FileSystem interface {
	Add(str ...string) FileSystem                     // 新增路径
	ReplaceRoot(str ...string) FileSystem             //替换根目录位置
	Dir() string                                      // 返回目录路径
	Base() string                                     // 返回路径中最后一个元素
	IsDir(dst ...string) bool                         // 判断是否为目录
	IsFile(dst ...string) bool                        // 判断是否为文件
	Ls(opt ...string) []string                        // 查看文件夹列表
	Find(opt ...string) []string                      // 查找文件
	MkDir(dst ...string) bool                         // 新建文件夹
	MkFile(dst ...string) (FileOperate, bool)         // 新建文件
	Write(src string, add ...bool) bool               // 写入文件
	ByteWriter(src []byte, add ...bool) (bool, error) // 通过Byte数组写入文件
	Open(add ...bool) (FileOperate, bool)             // 打开文件
	Exist(dst ...string) bool                         // 判断目录或文件是否存在
	Rm(dst ...string) bool                            // 删除目录或文件
	Rn(newname string) bool                           // 修改目录或文件名
	Mv(newpath string) bool                           // 移动目录或文件到指定位置
	Cp(dir string, overwrite bool) bool               // 拷贝目录或文件到指定位置
	Path() string                                     // 目录或文件名

	Ext() string // 返回文件扩展名
	MimeTypes() string
	MD5() string                   // 返回文件MD5
	SHA256() string                // 返回文件SHA256
	Config(conf interface{}) error // 加载配置文件
	Get() string                   // 返回路径
	Unzip() (string, error)
}

FileSystem ...

func FS

func FS(str ...string) FileSystem

FS 初始化...

type SnakeString

type SnakeString struct {
	Input string
}

func String

func String(str ...interface{}) *SnakeString

Text 初始化...

func (*SnakeString) Add

func (t *SnakeString) Add(str ...interface{}) *SnakeString

Add 在字符串中追加文字...

func (*SnakeString) AddSlice

func (t *SnakeString) AddSlice(dts []interface{}) *SnakeString

AddSlice 通过Slice在字符串中追加文字...

func (*SnakeString) Between

func (t *SnakeString) Between(start, end string) *SnakeString

Between 截取区间内容 ...

func (*SnakeString) Byte

func (t *SnakeString) Byte() []byte

Byte Function 获取字符串的Byte ...

func (*SnakeString) CamelCase

func (t *SnakeString) CamelCase() *SnakeString

CamelCase 驼峰分词: HelloWord ...

func (*SnakeString) Charset

func (t *SnakeString) Charset() (string, bool)

Charset Function 返回当前进程的字符集 ...

func (*SnakeString) Copy

func (t *SnakeString) Copy(length int) string

根据length循环复制字符串儿

func (*SnakeString) DeBase

func (t *SnakeString) DeBase(base int) *SnakeString

DeBase Text Base-x to Text: 2 < base > 36 ... 将2~36进制解码为Text

func (*SnakeString) DrawBox

func (t *SnakeString) DrawBox(width int, chars ...pkg.Box9Slice) *SnakeString

根据文字自动绘制代码提示框.

func (*SnakeString) EnBase

func (t *SnakeString) EnBase(base int) *SnakeString

EnBase Text to Base-x: 2 < base > 36 ... 将Text转为2~36进制编码

func (*SnakeString) ExistHan

func (t *SnakeString) ExistHan() bool

ExistHan Function 判断是否存在中文 ...

func (*SnakeString) ExistSlice

func (t *SnakeString) ExistSlice(dst []string) bool

ExistSlice 字符串是否存在于数组中 ...

func (*SnakeString) Extract

func (t *SnakeString) Extract(dst string, out ...string) []string

Extract 根据正则规则提取字符数组 ...

func (*SnakeString) Find

func (t *SnakeString) Find(dst string, noreg ...bool) bool

Find 判断字符串或符合正则规则的字符串是否存在 ...

func (*SnakeString) Get

func (t *SnakeString) Get() string

Get 获取文本...

func (*SnakeString) GetOneLine

func (t *SnakeString) GetOneLine() string

GetOneLine 在多行字符串中获取第一行字符串...

func (*SnakeString) IsGBK

func (t *SnakeString) IsGBK() bool

ExistGBK Function 判断是否为GBK ...

func (*SnakeString) IsUTF8

func (t *SnakeString) IsUTF8() bool

判断是否为UTF8

func (*SnakeString) KebabCase

func (t *SnakeString) KebabCase() *SnakeString

KebabCase "烤串儿"分词: hello-word ...

func (*SnakeString) Keep

func (t *SnakeString) Keep(dst string) *SnakeString

Keep 根据正则规则保留字符串 ...

func (*SnakeString) LF

func (t *SnakeString) LF() *SnakeString

以LF格式输出...

func (*SnakeString) LcFirst

func (t *SnakeString) LcFirst() *SnakeString

LCFirst 字符串首字母小写 ...

func (*SnakeString) Lines

func (t *SnakeString) Lines() []string

ss 根据行进行分割字符 ...

func (*SnakeString) Ln

func (t *SnakeString) Ln(line ...int) *SnakeString

LN 回车...

func (*SnakeString) Log

func (t *SnakeString) Log(str ...interface{}) *SnakeString

Add 在字符串中追加日志...

func (*SnakeString) MD5

func (t *SnakeString) MD5() string

MD5 获取字符串的MD5值

func (*SnakeString) Narrow

func (t *SnakeString) Narrow() *SnakeString

Narrow 全角字符转半角字符 ...

func (*SnakeString) ReComment

func (t *SnakeString) ReComment() *SnakeString

ReComment 去除代码注解...

func (*SnakeString) Remove

func (t *SnakeString) Remove(dst ...string) *SnakeString

Remove 根据正则规则删除字符串 ...

func (*SnakeString) Replace

func (t *SnakeString) Replace(src, dst string, noreg ...bool) *SnakeString

Replace 替换字符串或符合正则规则的字符串 ... snake.Text("http://www.teeif.com").Replace("(http://).*(teeif.com)", "${1}${2}") out: http://teeif.com snake.Text("http://www.example.com").Replace("example", "teeif") out: http://www.teeif.com 如需替换$等字符,请使用\\$ snake.Text("http://$1example.com").Replace("\\$1.*(.com)", "www.teeif${1}")

func (*SnakeString) ReplaceOne

func (t *SnakeString) ReplaceOne(src, dst string) *SnakeString

ReplaceOne 替换出现的第一个字符串 ...

func (*SnakeString) SHA256

func (t *SnakeString) SHA256() string

SHA256 获取字符串的SHA256值

func (*SnakeString) SM3

func (t *SnakeString) SM3() string

SM3 获取字符串的SM3值

func (*SnakeString) SnakeCase

func (t *SnakeString) SnakeCase() *SnakeString

SnakeCase 贪吃蛇分词: hello_word ...

func (*SnakeString) Split

func (t *SnakeString) Split(sep string) []string

Split 根据字符串进行文本分割 ...

func (*SnakeString) SplitInt

func (t *SnakeString) SplitInt(sep int) []string

SplitInt 根据设置对字符串等分 Text("abcdefg").SpltPlace([]int{1,3,4}) Out: []string{"a", "bc", "d", "efg"}

func (*SnakeString) SplitPlace

func (t *SnakeString) SplitPlace(sep []int) []string

SplitPlace 根据字符串的位置进行分割 Text("abcdefg").SpltPlace([]int{1,3,4}) Out: []string{"a", "bc", "d", "efg"}

func (*SnakeString) ToLower

func (t *SnakeString) ToLower() *SnakeString

ToLower 字符串全部小写 ...

func (*SnakeString) ToUTF8

func (t *SnakeString) ToUTF8() (string, bool)

ToUTF8 Function 运行对当前进程进行编码转换成UTF-8 ...

func (*SnakeString) ToUpper

func (t *SnakeString) ToUpper() *SnakeString

ToUpper 字符串全部小写 ...

func (*SnakeString) Trim

func (t *SnakeString) Trim(sep string) *SnakeString

Trim 去除开始及结束出现的字符 ...

func (*SnakeString) UcFirst

func (t *SnakeString) UcFirst() *SnakeString

UCFirst 字符串首字母大写 ...

func (*SnakeString) Unescape

func (t *SnakeString) Unescape() string

func (*SnakeString) Widen

func (t *SnakeString) Widen() *SnakeString

Widen 半角字符转全角字符 ...

func (*SnakeString) Write

func (t *SnakeString) Write(dst string, add ...bool) bool

Write 将数据写入指定文件 ... add为是否追加写入,默认为覆盖写入

type Tarlib

type Tarlib struct {
	Buffer   *bytes.Buffer
	FS       *tar.Writer
	Gzip     *bzip2.Writer
	FileName string
}

func Tar

func Tar(tarfile string) *Tarlib

func (*Tarlib) Add

func (t *Tarlib) Add(path string, stat fs.FileInfo, body []byte) bool

func (*Tarlib) Close

func (t *Tarlib) Close() error

type Ziplib

type Ziplib struct {
	Buffer   *bytes.Buffer
	FS       *zip.Writer
	FileName string
}

func Zip

func Zip(zipfile string) *Ziplib

func (*Ziplib) Add

func (z *Ziplib) Add(path string, body []byte) bool

func (*Ziplib) Close

func (z *Ziplib) Close() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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