utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(vs []string, f func(string) bool) bool

All returns true if all of the strings in the slice satisfy the predicate f.

func Any

func Any(vs []string, f func(string) bool) bool

Any returns true if one of the strings in the slice satisfies the predicate f.

func CamelCaseToSnakeCase

func CamelCaseToSnakeCase(name string) string

CamelCaseToSnakeCase returns a snake case string from a camel case string.

func ConvertToMySQLTableName

func ConvertToMySQLTableName(obj interface{}) string

ConvertToMySQLTableName convert the type name of a object to a table name. lower case

func ConvertToTableName

func ConvertToTableName(obj interface{}) string

ConvertToTableName convert the type name of a object to a table name. lower case and plural format

func Deref

func Deref(t reflect.Type) reflect.Type

Deref is Indirect for reflect.Types

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings in the slice that satisfy the predicate f.

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

GetFirstDateOfMonth 获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetFirstDateOfYear

func GetFirstDateOfYear(d time.Time) time.Time

GetFirstDateOfYear 获取传入的时间所在年份的第一天

func GetID

func GetID() int64

GetID return a snowflake ID.

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

GetLastDateOfMonth 获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetLastDateOfYear

func GetLastDateOfYear(d time.Time) time.Time

GetLastDateOfYear 获取传入的时间所在年份的最后一天

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

GetZeroTime 获取某一天的0点时间

func Include

func Include(vs []string, t string) bool

Include returns true if the target string t is in the slice.

func Index

func Index(vs []string, t string) int

Index returns the first index of the target string t, or -1 if no match is found.

func Map

func Map(vs []string, f func(string) string) []string

Map returns a new slice containing the results of applying the function f to each string in the original slice.

func MongoPipeline

func MongoPipeline(str string) mongo.Pipeline

MongoPipeline gets aggregation pipeline from a string

func ToSlice

func ToSlice(arr interface{}) []interface{}

ToSlice convert interface{} to []interface{}

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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