common

package
v8.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NA         = "N/A"
	ENABLED    = "enabled"
	DISABLED   = "disabled"
	SecretSalt = "Teamsacsca172021"
)

Variables

View Source
var (
	EmptyList      []interface{}
	EmptyData      map[string]interface{}
	ShangHaiLOC, _ = time.LoadLocation("Asia/Shanghai")
)

Functions

func Base642file

func Base642file(b64str string, file string) error

func CheckEmpty

func CheckEmpty(name string, v interface{})

func Copy

func Copy(from, to string) error

func CopyFile

func CopyFile(from io.Reader, to string, mode os.FileMode) error

func CreateTmpFile

func CreateTmpFile(data []byte) (*os.File, error)

create a file to test the upload and download.

func DeepCopy

func DeepCopy(value interface{}) interface{}

DeepCopy deep copy value

func DirExists

func DirExists(file string) bool

func EmptyToNA

func EmptyToNA(src string) string

func File2Base64

func File2Base64(file string) string

func FileExists

func FileExists(file string) bool

func FormatTimeDuration

func FormatTimeDuration(seconds int64) string

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

GbkToUtf8 GBK 转 UTF-8

func GenValidateCode

func GenValidateCode(width int) string

校验码生成

func GenerateDataVer

func GenerateDataVer() string

func GenerateRangeNum

func GenerateRangeNum(min, max int) int

func GetFieldType

func GetFieldType(mod interface{}, name string) string

func GetPointBool

func GetPointBool(s *bool) bool

func GetPointInt64

func GetPointInt64(s *int64) int64

func GetPointString

func GetPointString(s *string) string

func GetPointTime

func GetPointTime(s *time.Time) time.Time

func If

func If(condition bool, trueVal, falseVal interface{}) interface{}

func IfEmpty

func IfEmpty(src interface{}, defval interface{}) interface{}

func IfEmptyStr

func IfEmptyStr(src string, defval string) string

func IfNA

func IfNA(src string, defval string) string

func IgnoreError

func IgnoreError(v interface{}, err error) interface{}

func InSlice

func InSlice(v string, sl []string) bool

Determine if the string is in the list.

func IsEmpty

func IsEmpty(value interface{}) bool

IsEmpty checks if a value is empty or not. A value is considered empty if - integer, float: zero - bool: false - string, array: len() == 0 - slice, map: nil or len() == 0 - interface, pointer: nil or the referenced value is empty

func IsEmptyOrNA

func IsEmptyOrNA(val string) bool

func IsNotEmpty

func IsNotEmpty(value interface{}) bool

func IsNotEmptyAndNA

func IsNotEmptyAndNA(val string) bool

func JsonMarshal

func JsonMarshal(v interface{}) ([]byte, error)

func JsonUnmarshal

func JsonUnmarshal(data []byte, v interface{}) error

func MakeDir

func MakeDir(path string)

MakeDir 创建目录

func Md5Hash

func Md5Hash(src string) string

func Md5HashFile

func Md5HashFile(filePath string) (string, error)

func MobileAgent

func MobileAgent(userAgent string) string

func Must

func Must(err error)

panic error

func Must2

func Must2(v interface{}, err error) interface{}

func MustCallBefore

func MustCallBefore(err error, callbefore func())

func MustDebug

func MustDebug(err error, debug bool)

panic error

func MustNotEmpty

func MustNotEmpty(name string, v interface{})

func MustStringValue

func MustStringValue(val string, err error) string

panic error

func NextDataVar

func NextDataVar() string

func ParseFloat64

func ParseFloat64(v interface{}) (float64, error)

func ParseInt64

func ParseInt64(v interface{}) (int64, error)

func ParseString

func ParseString(v interface{}) (string, error)

func ReplaceNaN

func ReplaceNaN(v float64, r float64) float64

func SetEmptyStrToNA

func SetEmptyStrToNA(t interface{})

func Sha1Hash

func Sha1Hash(src string) string

func Sha256Hash

func Sha256Hash(src string) string

func Sha256HashWithSalt

func Sha256HashWithSalt(src string, salt string) string

func StructToMap

func StructToMap(obj interface{}) (newMap map[string]interface{}, err error)

func ToCamelCase

func ToCamelCase(str string) string

Convert to Big Hump format

func ToGbkHexString

func ToGbkHexString(src string) (string, error)

func ToGbkString

func ToGbkString(src string) (string, error)

func ToJson

func ToJson(v interface{}) string

func ToSnakeCase

func ToSnakeCase(str string) string

Convert to underlined format

func TrimBytes

func TrimBytes(src []byte) []byte

func UUID

func UUID() string

func UUIDBase32

func UUIDBase32() (string, error)

func UUIDint64

func UUIDint64() int64

Generate int64

func UrlJoin

func UrlJoin(hurl string, elm ...string) string

func UrlJoin2

func UrlJoin2(hurl string, elm ...string) string

func Usage

func Usage(str string)

Usage print usage

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Utf8ToGbk UTF-8 转 GBK

Types

This section is empty.

Directories

Path Synopsis
This package wraps the standard XML library and uses it to build a node tree of any document you load.
This package wraps the standard XML library and uses it to build a node tree of any document you load.
log

Jump to

Keyboard shortcuts

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