commons

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileMode os.FileMode = 0644
	DefaultDirMode  os.FileMode = 0755
	FileSeparator               = filepath.Separator
)
View Source
const (
	FormatTimeV1 = "2006-01-02 15:04:05"
	FormatTimeV2 = "2006/1-2"
)

Variables

View Source
var (
	FormatPrettyJson = prettyjson.Format
)

Functions

func ContainsString

func ContainsString(str []string, elem string) bool

func Exist

func Exist(filename string) bool

Exist 判断文件是否存在.

func Float642String

func Float642String(num float64, saveDecimalPoint int) string

Float642String 除固定值,保留固定小数位.

func FormatFloat

func FormatFloat(i float64, size int) string

func GenerateUUID

func GenerateUUID() string

func GetAllFiles

func GetAllFiles(dirPth string, filter FilterFile) ([]string, error)

GetAllFiles 从路径dirPth下获取全部的文件.

func GetFileAbsPath

func GetFileAbsPath(path string) (string, error)

func GetFilePrefixAndSuffix

func GetFilePrefixAndSuffix(filename string) (prefix, suffix string)

func GetFileRelativePath

func GetFileRelativePath(fileName string, path string) (string, error)

GetFileRelativePath fileName指的是文件的路径 path 指的是文件的父路径地址,return 相对路径.

func GetGoPath added in v1.1.1

func GetGoPath() string

func GetGoProjectDir

func GetGoProjectDir() string

GetGoProjectDir 有 go.mod 的目录.

func LinesToString

func LinesToString(lines []string) string

func NewString

func NewString(elem byte, len int) string

func ReadLineByFunc

func ReadLineByFunc(file io.Reader, foo func(line string) error) error

func ReadLines

func ReadLines(read io.Reader) ([]string, error)

func Slug

func Slug(str string) string

func SplitSliceString

func SplitSliceString(slice []string, length int) [][]string

func TimeToSeconds

func TimeToSeconds(duration time.Duration) string

TimeToSeconds 时间之差 s 输出 0.100010s.

func ToJsonString

func ToJsonString(v interface{}) string

func ToPrettyJsonString

func ToPrettyJsonString(v interface{}) string

func ToString

func ToString(value interface{}) string

func UnsafeBytes

func UnsafeBytes(data string) []byte

func UnsafeString

func UnsafeString(data []byte) string

Types

type FilterFile

type FilterFile func(fileName string) bool

Directories

Path Synopsis
internal
prettyjson
* COPY https://github.com/hokaccha/go-prettyjson/blob/master/prettyjson.go Package prettyjson provides JSON pretty print.
* COPY https://github.com/hokaccha/go-prettyjson/blob/master/prettyjson.go Package prettyjson provides JSON pretty print.
unsafe
Package unsafeConvert provides functions for unsafely convert between a string and a slice of bytes.
Package unsafeConvert provides functions for unsafely convert between a string and a slice of bytes.

Jump to

Keyboard shortcuts

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