Documentation ¶
Index ¶
- Constants
- func Base64Decode(input string) ([]byte, error)
- func Base64Encode(input []byte) string
- func ByteArrayToString(input []byte) string
- func CalculateAmountWithFee(amount, fee float64) float64
- func CalculateFee(amount, fee float64) float64
- func CalculateNetProfit(amount, priceThen, priceNow, costs float64) float64
- func CalculatePercentageDifference(amount, secondAmount float64) float64
- func CalculatePercentageGainOrLoss(priceNow, priceThen float64) float64
- func CreateDir(dir string) error
- func EncodeURLValues(url string, values url.Values) string
- func ExtractHost(address string) string
- func ExtractPort(host string) int
- func FloatFromString(raw interface{}) (float64, error)
- func FloatFromStringDontRound(num float64, exp int) (result float64, err error)
- func FormatDecimalFloat64(value float64, exp int32) float64
- func FormatDecimalString(value float64, exp int32) string
- func FormatMapStringToString(msg string, fileds map[string]interface{}) string
- func GetCaller() (filePath, fileName, funcName string, lineNum int)
- func GetExecutablePath() (string, error)
- func GetFuncLine() int
- func GetFuncName() string
- func GetHMAC(hashType int, input, key []byte) []byte
- func GetMD5(input []byte) []byte
- func GetOSPathSlash() string
- func GetRandomSalt(input []byte, saltLen int) ([]byte, error)
- func GetSHA256(input []byte) []byte
- func GetSHA512(input []byte) []byte
- func GetURIPath(uri string) string
- func HexDecodeToBytes(input string) ([]byte, error)
- func HexEncodeToString(input []byte) string
- func Int32FromString(raw interface{}) (int32, error)
- func Int32ToString(n int32) string
- func Int64DataCompare(haystack []int64, needle int64) bool
- func Int64FromString(raw interface{}) (int64, error)
- func IntDataCompare(haystack []int, needle int) bool
- func IntFromString(raw interface{}) (int, error)
- func IsEnabled(isEnabled bool) string
- func IsValidCryptoAddress(address, crypto string) (bool, error)
- func JSONDecode(data []byte, to interface{}) error
- func JSONEncode(v interface{}) ([]byte, error)
- func JoinStrings(input []string, separator string) string
- func NewHTTPClientWithTimeout(t time.Duration) *http.Client
- func OutputCSV(path string, data [][]string) error
- func PathExists(path string) bool
- func ReadFile(path string) ([]byte, error)
- func RecvWindow(d time.Duration) int64
- func RemoveFile(file string) error
- func ReplaceString(input, old, new string, n int) string
- func RoundFloat(x float64, prec int) float64
- func Sha1ToHex(data string) string
- func SplitStrings(input, separator string) []string
- func StringContains(input, substring string) bool
- func StringDataCompare(haystack []string, needle string) bool
- func StringDataCompareInsensitive(haystack []string, needle string) bool
- func StringDataCompareUpper(haystack []string, needle string) bool
- func StringDataContains(haystack []string, needle string) bool
- func StringDataContainsInsensitive(haystack []string, needle string) bool
- func StringDataContainsUpper(haystack []string, needle string) bool
- func StringSliceDifference(slice1 []string, slice2 []string) []string
- func StringToLower(input string) string
- func StringToUpper(input string) string
- func TimeDataCompare(haystack []time.Time, needle time.Time) bool
- func TimeFromUnixEscInt64(i int64) time.Time
- func TimeFromUnixNEscInt64(i int64) time.Time
- func TimeFromUnixTimestampFloat(raw interface{}) (time.Time, error)
- func TrimString(input, cutset string) string
- func UnixNesc(t time.Time) int64
- func UnixTimestampStrToTime(timeStr string) (time.Time, error)
- func UnixTimestampToTime(timeint64 int64) time.Time
- func WriteFile(file string, data []byte) error
- func YesOrNo(input string) bool
Constants ¶
const ( HashSHA1 = iota HashSHA256 HashSHA512 HashSHA512_384 MD5New SatoshisPerBTC = 100000000 SatoshisPerLTC = 100000000 WeiPerEther = 1000000000000000000 )
Const declarations for common.go operations
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64Decode takes in a Base64 string and returns a byte array and an error
func Base64Encode ¶
Base64Encode takes in a byte array then returns an encoded base64 string
func ByteArrayToString ¶
ByteArrayToString returns a string
func CalculateAmountWithFee ¶
CalculateAmountWithFee returns a calculated fee included amount on fee
func CalculateFee ¶
CalculateFee returns a simple fee on amount
func CalculateNetProfit ¶
CalculateNetProfit returns net profit
func CalculatePercentageDifference ¶
CalculatePercentageDifference returns the percentage of difference between multiple time periods
func CalculatePercentageGainOrLoss ¶
CalculatePercentageGainOrLoss returns the percentage rise over a certain period
func EncodeURLValues ¶
EncodeURLValues concatenates url values onto a url string and returns a string
func ExtractHost ¶
ExtractHost returns the hostname out of a string
func ExtractPort ¶
ExtractPort returns the port name out of a string
func FloatFromString ¶
FloatFromString format
func FloatFromStringDontRound ¶
FloatFromStringDontRound 不需要小数点四舍五入,直接取位数
func FormatDecimalFloat64 ¶
FormatDecimalFloat64 获取精度计算后的数量String @param {[type]} this [description] @return {[type]} [description]
func FormatDecimalString ¶
FormatDecimalString 格式化后的字符串 @param {[type]} this [description] @return {[type]} [description] formatDecimal_String("0.000163786", -6) //"0.000164"
func FormatMapStringToString ¶
FormatMapStringToString 将 map[string]interface{} 格式化成字符串 commonutils.FormatMapStringToString("买进补仓", logFileds)
func GetExecutablePath ¶
GetExecutablePath returns the executables launch path
func GetOSPathSlash ¶
func GetOSPathSlash() string
GetOSPathSlash returns the slash used by the operating systems file system
func GetRandomSalt ¶
GetRandomSalt returns a random salt
func GetURIPath ¶
GetURIPath returns the path of a URL given a URI
func HexDecodeToBytes ¶
HexDecodeToBytes takes in a hexadecimal string and returns a byte array
func HexEncodeToString ¶
HexEncodeToString takes in a hexadecimal byte array and returns a string
func Int64DataCompare ¶
Int64DataCompare data checks the substring array with an input and returns a bool
func IntDataCompare ¶
IntDataCompare data checks the substring array with an input and returns a bool
func IsEnabled ¶
IsEnabled takes in a boolean param and returns a string if it is enabled or disabled
func IsValidCryptoAddress ¶
IsValidCryptoAddress validates your cryptocurrency address string using the regexp package // Validation issues occurring because "3" is contained in litecoin and Bitcoin addresses - non-fatal
func JSONDecode ¶
JSONDecode decodes JSON data into a structure
func JSONEncode ¶
JSONEncode encodes structure data into JSON
func JoinStrings ¶
JoinStrings joins an array together with the required separator and returns it as a string
func NewHTTPClientWithTimeout ¶
NewHTTPClientWithTimeout initialises a new HTTP client with the specified timeout duration
func ReplaceString ¶
ReplaceString replaces a string with another 返回将s中前n个不重叠old子串都替换为new的新字符串,如果n<0会替换所有old子串。
func RoundFloat ¶
RoundFloat rounds your floating point number to the desired decimal place
func SplitStrings ¶
SplitStrings splits blocks of strings from string into a string array using a separator ie "," or "_"
func StringContains ¶
StringContains checks a substring if it contains your input then returns a bool
func StringDataCompare ¶
StringDataCompare data checks the substring array with an input and returns a bool
func StringDataCompareInsensitive ¶
StringDataCompareInsensitive data checks the substring array with an input and returns a bool irrespective of lower or upper case strings
func StringDataCompareUpper ¶
StringDataCompareUpper data checks the substring array with an input and returns a bool irrespective of lower or upper case strings
func StringDataContains ¶
StringDataContains checks the substring array with an input and returns a bool
func StringDataContainsInsensitive ¶
StringDataContainsInsensitive checks the substring array with an input and returns a bool irrespective of lower or upper case strings
func StringDataContainsUpper ¶
StringDataContainsUpper checks the substring array with an input and returns a bool irrespective of lower or upper case strings
func StringSliceDifference ¶
StringSliceDifference concatenates slices together based on its index and returns an individual string array
func StringToLower ¶
StringToLower changes strings to lowercase
func StringToUpper ¶
StringToUpper changes strings to uppercase
func TimeDataCompare ¶
TimeDataCompare data checks the substring array with an input and returns a bool
func TimeFromUnixEscInt64 ¶
TimeFromUnixEscInt64 format i := int64(1530854162) fmt.Println(TimeFromUnixNescInt64(i)) //2018-07-06 13:16:02
func TimeFromUnixNEscInt64 ¶
TimeFromUnixNEscInt64 format i := int64(1532246192000) t := commonutils.TimeFromUnixEscInt64(i) fmt.Println(t.Format("2006-01-02 15:04:05")) //2018-07-22 15:56:32
func TimeFromUnixTimestampFloat ¶
TimeFromUnixTimestampFloat format
func TrimString ¶
TrimString trims unwanted prefixes or postfixes
func UnixNesc ¶
UnixNesc 格式化时间 i := int64(1532246192000) t := commonutils.TimeFromUnixNEscInt64(i) fmt.Println(t.Format("2006-01-02 15:04:05")) //2018-07-22 15:56:32 fmt.Println(commonutils.UnixNesc(t)) // 1532246192000
func UnixTimestampStrToTime ¶
UnixTimestampStrToTime returns a time.time and an error
func UnixTimestampToTime ¶
UnixTimestampToTime returns time.time
Types ¶
This section is empty.