Documentation ¶
Index ¶
- func AppName() string
- func BatchSliceOfStrings(ctx context.Context, keys []string, count int) <-chan []string
- func ChanFromSlice[T any](values []T) <-chan T
- func Checksum(data interface{}) []byte
- func ConvertCamelCase(s string, _case int, sep byte) string
- func Ellipsize(s string, limit int) string
- func Fatal(err error)
- func FromUnixMilli(ms int64) time.Time
- func IsContextCanceled(err error) bool
- func IsDeadlock(err error) bool
- func JoinHostPort(host string, port int) string
- func Key(name string, sep byte) string
- func MaxInt(x, y int) int
- func Name(t interface{}) string
- func TableName(t interface{}) string
- func Timed(start time.Time, callback func(elapsed time.Duration))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppName ¶
func AppName() string
AppName returns the name of the executable that started this program (process).
func BatchSliceOfStrings ¶
BatchSliceOfStrings groups the given keys into chunks of size count and streams them into a returned channel.
func ChanFromSlice ¶ added in v1.1.1
func ChanFromSlice[T any](values []T) <-chan T
ChanFromSlice takes a slice of values and returns a channel from which these values can be received. This channel is closed after the last value was sent.
func Checksum ¶
func Checksum(data interface{}) []byte
Checksum returns the SHA-1 checksum of the data.
func ConvertCamelCase ¶
ConvertCamelCase converts a (lower) CamelCase string into various cases. _case must be unicode.Lower or unicode.Upper.
Example usage:
# snake_case ConvertCamelCase(s, unicode.Lower, '_') # SCREAMING_SNAKE_CASE ConvertCamelCase(s, unicode.Upper, '_') # kebab-case ConvertCamelCase(s, unicode.Lower, '-') # SCREAMING-KEBAB-CASE ConvertCamelCase(s, unicode.Upper, '-') # other.separator ConvertCamelCase(s, unicode.Lower, '.')
func FromUnixMilli ¶
FromUnixMilli creates and returns a time.Time value from the given milliseconds since the Unix epoch ms.
func IsContextCanceled ¶
IsContextCanceled returns whether the given error is context.Canceled.
func IsDeadlock ¶
IsDeadlock returns whether the given error signals serialization failure.
func JoinHostPort ¶ added in v1.1.1
JoinHostPort is like its equivalent in net., but handles UNIX sockets as well.
func Key ¶
Key returns the name with all Unicode letters mapped to lower case letters, with an additional separator in front of each original upper case letter.
func Name ¶
func Name(t interface{}) string
Name returns the declared name of type t. Name is used in combination with Key to automatically guess an entity's database table and Redis key.
Types ¶
This section is empty.