utif

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 15 Imported by: 0

README

utif

utif stands for Utility Functions, different functions to facilitate common tasks

Documentation

Overview

Package utif stands for Utility Functions, providing different functions to facilitate common tasks

Package utif stands for Utility Functions, providing different functions to facilitate common tasks

Package utif stands for Utility Functions, providing different functions to facilitate common tasks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FloatValue

func FloatValue(intValue sql.NullFloat64) float64

FloatValue return float value from sql.NullFloat64, if has invalid value then zero value will be returned.

func FloatsliceToCSV added in v0.0.2

func FloatsliceToCSV(a []float64, sep string) string

sliceToStringFloat convert slice to float64 to comma separated string

func Int64SliceToCSV added in v0.0.2

func Int64SliceToCSV(a []int64, sep string) string

Int64SliceToCSV convert slice of int64 to comma separated string

func IntSliceToCSV

func IntSliceToCSV(a []int, sep string) string

IntSliceToCSV convert slice of int to comma separated string

func IntValue

func IntValue(intValue sql.NullInt32) int32

IntValue return int value from sql.NullInt32, if has invalid value then zero value will be returned.

func IsValidEmail added in v0.0.3

func IsValidEmail(email string) bool

func IsValidIp added in v0.0.3

func IsValidIp(ip string) bool

func JSONStringToStruct

func JSONStringToStruct(jsonstring string, dest interface{}) error

JSONStringToStruct convert JSON string to given struct

func MD5Str

func MD5Str(s, salt string) string

MD5Str gives MD5 hash of given string and salt

func MD5Struct

func MD5Struct(o interface{}, salt string) string

MD5Struct gives MD5 hash of given struct and salt

func RandStringAlpha

func RandStringAlpha(lenght int) string

RandStringAlpha returns random alphabet string of given length

func RandStringAlphaNumeric

func RandStringAlphaNumeric(lenght int) string

RandStringAlphaNumeric returns random alpha-numeric string of given length

func RandStringNumeric

func RandStringNumeric(lenght int) string

RandStringNumeric returns random numeric string of given length

func Sha256Str

func Sha256Str(s, salt string) string

Sha256Str gives SHA256 hash of given string and salt

func Sha256Struct

func Sha256Struct(o interface{}, salt string) string

Sha256Struct gives SHA256 hash of given struct and salt

func StoI

func StoI(array interface{}) []interface{}

StoI converts slice of struct to slice of interface

func StringValue

func StringValue(stringValue sql.NullString) string

StringValue return string value from sql.NullString, if has invalid value then zero value will be returned.

func StructToJSON

func StructToJSON(d interface{}) ([]byte, error)

StructToJSON convert given struct to JSON []byte

func StructToJSONString

func StructToJSONString(d interface{}) (string, error)

StructToJSONString convert given struct to JSON

func TimeTrack

func TimeTrack(start time.Time)

TimeTrack allow to time given function by passing it start time. Caller function name will be extacted from runtime.

func TimeValue

func TimeValue(timeValue sql.NullTime) time.Time

TimeValue return time value from sql.NullTime, if has invalid value then 1900-01-01 will be returned.

func ToString

func ToString(t interface{}) (string, bool)

ToString try to convert given interface to string

func ToStringx

func ToStringx(t interface{}) string

ToStringx try to convert given struct to string if any error occur then return blank string

func Track

func Track(start time.Time, fnname string)

Track given time elapsed since start time. fnname is name of function to print in log.

Types

This section is empty.

Jump to

Keyboard shortcuts

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