converter

package
v0.0.0-...-926aee0 Latest Latest
Warning

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

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

Documentation

Overview

Package converter 格式, 类型转换包

Index

Constants

View Source
const (
	// B byte
	B = (int64)(1 << (10 * iota))
	// KB kilobyte
	KB
	// MB megabyte
	MB
	// GB gigabyte
	GB
	// TB terabyte
	TB
	// PB petabyte
	PB
)
View Source
const (
	// InvalidChars 文件名中的非法字符
	InvalidChars = `\/:*?"<>|`
)

Variables

This section is empty.

Functions

func ConvertFileSize

func ConvertFileSize(size int64, precision ...int) string

ConvertFileSize 文件大小格式化输出

func IntToBool

func IntToBool(i int) bool

IntToBool int 类型转换为 bool

func MustInt

func MustInt(s string) (n int)

MustInt 将string转换为int, 忽略错误

func MustInt64

func MustInt64(s string) (i int64)

MustInt64 将string转换为int64, 忽略错误

func ParseFileSizeStr

func ParseFileSizeStr(ss string) (size int64, err error)

ParseFileSizeStr 将文件大小字符串转换成字节数

func ShortDisplay

func ShortDisplay(s string, num int) string

ShortDisplay 缩略显示字符串s, 显示长度为num, 缩略的内容用"..."填充

func SliceInt64ToString

func SliceInt64ToString(si []int64) (ss []string)

SliceInt64ToString []int64 转换为 []string

func SliceStringToInt

func SliceStringToInt(ss []string) (si []int)

SliceStringToInt []string 转换为 []int

func SliceStringToInt64

func SliceStringToInt64(ss []string) (si []int64)

SliceStringToInt64 []string 转换为 []int64

func ToBytes

func ToBytes(str string) []byte

ToBytes unsafe 转换, 将 string 转换为 []byte

func ToBytesUnsafe

func ToBytesUnsafe(str string) []byte

ToBytesUnsafe unsafe 转换, 请确保转换后的 []byte 不涉及 cap() 操作, 将 string 转换为 []byte

func ToString

func ToString(p []byte) string

ToString unsafe 转换, 将 []byte 转换为 string

func TrimPathInvalidChars

func TrimPathInvalidChars(fpath string) string

TrimPathInvalidChars 清除文件名中的非法字符

Types

This section is empty.

Jump to

Keyboard shortcuts

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