utils

package
v0.0.0-...-ab5a54e Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package utils provides file path dependent methods

Package utils provides file path dependent methods

Package utils provides file path dependent methods

Package utils provides file path dependent methods

Package utils provides file path dependent methods

Package utils provides file path dependent methods

Index

Constants

View Source
const (
	NamingLower string = "lower"
	NamingCamel string = "camel"
	NamingSnake string = "snake"
)
View Source
const (
	NL = "\n"
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) (int64, error)

拷贝文件

func CreateIfNotExist

func CreateIfNotExist(file string) (*os.File, error)

不存在则创建文件

func FileExists

func FileExists(file string) bool

文件是否存在

func FormatFilename

func FormatFilename(filename string, style string) string

格式化文件名

func GetTemplateDir

func GetTemplateDir(category string) (string, error)

func GetTemplateHome

func GetTemplateHome() (string, error)

func IsNamingValid

func IsNamingValid(name string) (string, bool)

命名风格是否有效

func LoadTemplate

func LoadTemplate(category, file, builtin string) (string, error)

加载模板

func MaybeCreateFile

func MaybeCreateFile(dir, subDir, file string) (*os.File, bool, error)

可能创建文件,如果有创建文件,返回文件句柄

func MkdirIfNotExist

func MkdirIfNotExist(dir string) error

如果不存在则创建目录

func PathExists

func PathExists(path string) (bool, error)

目录是否存在

func RemoveIfExist

func RemoveIfExist(filename string) error

存在则删除文件

func RunCMD

func RunCMD(arg string, dir string, in ...*bytes.Buffer) (string, error)

执行命令

Types

type String

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

自定义的String结构体

func StringFrom

func StringFrom(data string) String

StringFrom

func (String) IsEmptyOrSpace

func (s String) IsEmptyOrSpace() bool

判断字符串是否为空

func (String) Lower

func (s String) Lower() string

转小写

func (String) ReplaceAll

func (s String) ReplaceAll(old, new string) string

全部替换

func (String) Source

func (s String) Source() string

源字符串

func (String) Title

func (s String) Title() string

返回单词首字母大写的拷贝字符串

func (String) ToCamel

func (s String) ToCamel() string

蛇形转驼峰格式

func (String) ToSnake

func (s String) ToSnake() string

驼峰转蛇形格式

func (String) Untitled

func (s String) Untitled() string

return original string if rune is not letter at index 0

func (String) Upper

func (s String) Upper() string

转大写

Jump to

Keyboard shortcuts

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