libcore

package module
v0.0.0-...-ec00206 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: GPL-3.0 Imports: 18 Imported by: 2

README

Many stupid functions


1) Get this: git clone https://github.com/progman/libcore.go.git
2) Enjoy!

Documentation

Overview

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bin2Hex

func Bin2Hex(src []byte) (out string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func BoolToFlag

func BoolToFlag(source bool) (target string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func DecAdd

func DecAdd(source string, add string) (target string, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func DecCmp

func DecCmp(s1 string, s2 string) int

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

DecCmp() returns an integer indicating the result of the comparison, as follows:

• 0, if the s1 and s2 are equal;

• a negative value if s1 is less than s2;

• a positive value if s1 is greater than s2.

func DecCrop

func DecCrop(str string) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func DecExpand

func DecExpand(str string, size int) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func DecSignToDec

func DecSignToDec(decSign byte) (dec byte)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func DecTest

func DecTest() (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func FlagToBool

func FlagToBool(source string) (target bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func FloatToStr

func FloatToStr(source float64) (target string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func FormatAmount

func FormatAmount(amount, currencyName, dotSign string) (amountFormated string, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// *

  • @author Alexey Potehin <gnuplanet@gmail.com>, http://www.gnuplanet.online/doc/cv
  • @brief format amount, example: 1 -> 0.01 for USD
  • @param amount amount of coins, example: 100 is 1 dollar
  • @param currencyName name of currency (ISO4217)
  • @param dotSign separator, example: .
  • @return amountFormated formated amount
  • @return err error

func FormatAmountTest

func FormatAmountTest() (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetRandHex

func GetRandHex(size int) (str string, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetRandRange

func GetRandRange(min int64, max int64) (rnd int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetRandUUID

func GetRandUUID() (randUUID string, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetRandСhance

func GetRandСhance(percent int) (chance bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// if event will be 80% then %80 times return true else false

func GetUnixmicrotimeUtc

func GetUnixmicrotimeUtc() (unixmicrotimeUtc string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetUnixmicrotimeUtcInt64

func GetUnixmicrotimeUtcInt64() (unixmicrotimeUtc int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetUnixnanotimeUtc

func GetUnixnanotimeUtc() (unixnanotimeUtc string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetUnixnanotimeUtcInt64

func GetUnixnanotimeUtcInt64() (unixnanotimeUtc int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetValueSint

func GetValueSint(r *http.Request, key string, defaultValue int64) (value int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetValueStr

func GetValueStr(r *http.Request, key string, defaultValue string) (value string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetValueStrList

func GetValueStrList(r *http.Request, key string, defaultValue []string) (value []string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetValueUint

func GetValueUint(r *http.Request, key string, defaultValue uint64) (value uint64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func Hex2Bin

func Hex2Bin(src string) (dst []byte, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HexAdd

func HexAdd(source string, add string) (target string, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HexCmp

func HexCmp(s1 string, s2 string) int

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

HexCmp() returns an integer indicating the result of the comparison, as follows:

• 0, if the s1 and s2 are equal;

• a negative value if s1 is less than s2;

• a positive value if s1 is greater than s2.

func HexCrop

func HexCrop(str string) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HexExpand

func HexExpand(str string, size int) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HexParity

func HexParity(str string) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HexSignToDec

func HexSignToDec(hexSign byte) (dec byte)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HexTest

func HexTest() (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func HttpDelete

func HttpDelete(url string, pHeaderMap *map[string]string, timeout time.Duration) (httpCode int, dataOut []byte, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// *

  • @author Alexey Potehin <gnuplanet@gmail.com>, http://www.gnuplanet.online/doc/cv
  • @brief send DELETE request to url
  • @param url URL
  • @param pHeaderMap header map, map[string]string{"Content-Type": "application/json", "Authorization": "Bearer xxx"}
  • @param timeout timeout like 30 * time.Second
  • @return httpCode http status code
  • @return dataOut received data
  • @return err error

func HttpGet

func HttpGet(url string, pHeaderMap *map[string]string, timeout time.Duration) (httpCode int, dataOut []byte, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// *

  • @author Alexey Potehin <gnuplanet@gmail.com>, http://www.gnuplanet.online/doc/cv
  • @brief send GET request to url
  • @param accessToken access token OR empty string
  • @param url URL
  • @param pHeaderMap header map, map[string]string{"Content-Type": "application/json", "Authorization": "Bearer xxx"}
  • @param timeout timeout like 30 * time.Second
  • @return httpCode http status code
  • @return dataOut received data
  • @return err error

func HttpPost

func HttpPost(url string, pHeaderMap *map[string]string, timeout time.Duration, dataIn []byte) (httpCode int, dataOut []byte, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// *

  • @author Alexey Potehin <gnuplanet@gmail.com>, http://www.gnuplanet.online/doc/cv
  • @brief send POST request to url
  • @param accessToken access token OR empty string
  • @param url URL
  • @param pHeaderMap header map, map[string]string{"Content-Type": "application/json", "Authorization": "Bearer xxx"}
  • @param timeout timeout like 30 * time.Second
  • @param dataIn data for send
  • @return httpCode http status code
  • @return dataOut received data
  • @return err error

func HttpPut

func HttpPut(url string, pHeaderMap *map[string]string, timeout time.Duration, dataIn []byte) (httpCode int, dataOut []byte, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// *

  • @author Alexey Potehin <gnuplanet@gmail.com>, http://www.gnuplanet.online/doc/cv
  • @brief send PUT request to url
  • @param accessToken access token OR empty string
  • @param url URL
  • @param pHeaderMap header map, map[string]string{"Content-Type": "application/json", "Authorization": "Bearer xxx"}
  • @param timeout timeout like 30 * time.Second
  • @param dataIn data for send
  • @return httpCode http status code
  • @return dataOut received data
  • @return err error

func IsDec

func IsDec(str string) (isDec bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsDecSign

func IsDecSign(val byte) (isDec bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsDockerContainer

func IsDockerContainer() (flagDocker bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsFloat

func IsFloat(str string, flagNeedDot bool) (flagOk bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// import (

"errors"

) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

""    - false
"1"   - true (for flagNeedDot == false) or false (for flagNeedDot == true)
".1"  - true
"1."  - true
"."   - false
".1." - false
"x"   - false

func IsFloatStrEqual

func IsFloatStrEqual(floatStr1 string, floatStr2 string) (flagEqual bool, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

1      err
1 2    false
1 1    true
1 1.   true
1 1.0  true
1 1.00 true

func IsHex

func IsHex(str string) (isHex bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsHexSign

func IsHexSign(val byte) (isHex bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsInt64InArray

func IsInt64InArray(arr []int64, val int64) bool

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsIsoDatetime

func IsIsoDatetime(dateStr string) (flagOk bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsParity

func IsParity(val uint64) bool

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsSint

func IsSint(str string) (flagOk bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsStringInArray

func IsStringInArray(arr []string, val string) bool

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsUint

func IsUint(str string) (flagOk bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsUint64InArray

func IsUint64InArray(arr []uint64, val uint64) bool

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func IsoToUnixnanotime

func IsoToUnixnanotime(iso string) (unixnanotime int64, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// "2025-03-16T02:01:57+03:00" -> 1742079717000000000 (2025-03-15 23:01:57 +0000 UTC)

func LuhnCheck

func LuhnCheck(val string) (flagOk bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func LuhnMake

func LuhnMake(str string) (a string, flagOk bool)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func LuhnTest

func LuhnTest() (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func Ping

func Ping() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func Pong

func Pong() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostBodyStr

func PostBodyStr(r *http.Request, defaultValue string) (value string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostJsonValueStr

func PostJsonValueStr(body string, key string, defaultValue string) (value string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostJsonValueStrList

func PostJsonValueStrList(body string, key string, defaultValue []string) (value []string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostParse

func PostParse(r *http.Request) (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostParseMultipart

func PostParseMultipart(r *http.Request, maxMemory int64) (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostValueFile

func PostValueFile(r *http.Request, key string, defaultValue []byte) (filename string, value []byte)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func MPostValueStr(r *http.Request, key string, defaultValue string) (value string) {
	var err error

	if len(r.Form) == 0 {
		err = r.ParseMultipartForm(1024 * 1024 * 10)
		if err != nil {
			value = defaultValue
			return
		}
	}

// value = r.PostForm.Get(key)

value = r.Form.Get(key)

// tmp := r.URL.Query()[key] // if (len(tmp) == 0) { // value = defaultValue // return // } // value = tmp[0]

	return
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func MPostValueUint(r *http.Request, key string, defaultValue uint64) (value uint64) {
	var err error

	valueStr := MPostValueStr(r, key, fmt.Sprintf("%d", defaultValue))

	if IsUint(valueStr) == false {
		value = defaultValue
		return
	}

	valueTmp, err := strconv.ParseUint(valueStr, 10, 64)
	if err != nil {
		value = defaultValue
		return
	}
	value = uint64(valueTmp)

	return
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func MPostValueSint(r *http.Request, key string, defaultValue int64) (value int64) {
	var err error

	valueStr := MPostValueStr(r, key, fmt.Sprintf("%d", defaultValue))

	if IsSint(valueStr) == false {
		value = defaultValue
		return
	}

	valueTmp, err := strconv.ParseInt(valueStr, 10, 64)
	if err != nil {
		value = defaultValue
		return
	}
	value = int64(valueTmp)

	return
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostValueSint

func PostValueSint(r *http.Request, key string, defaultValue int64) (value int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostValueStr

func PostValueStr(r *http.Request, key string, defaultValue string) (value string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func PostValueUint

func PostValueUint(r *http.Request, key string, defaultValue uint64) (value uint64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func SetByteInString

func SetByteInString(str string, index int, val byte) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func SintToStr

func SintToStr(value int64) (str string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func StrExpandLeft

func StrExpandLeft(source string, size int, filler string) (target string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func StrExpandRight

func StrExpandRight(source string, size int, filler string) (target string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func StrToFloat

func StrToFloat(str string) (value float64, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func StrToSint

func StrToSint(str string) (value int64, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func StrToUint

func StrToUint(str string) (value uint64, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func StringArrayToString

func StringArrayToString(source []string) (target string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func SubByte

func SubByte(buf []byte, start_index int, size int) []byte

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// [9 8 7 6 5 4 3 2 1], 0, 20 -> [9 8 7 6 5 4 3 2 1] [9 8 7 6 5 4 3 2 1], 0, 9 -> [9 8 7 6 5 4 3 2 1] [9 8 7 6 5 4 3 2 1], 0, 8 -> [9 8 7 6 5 4 3 2] [9 8 7 6 5 4 3 2 1], 1, 8 -> [8 7 6 5 4 3 2 1] [9 8 7 6 5 4 3 2 1], 2, 8 -> [7 6 5 4 3 2 1] [9 8 7 6 5 4 3 2 1], 2, 9 -> [7 6 5 4 3 2 1] [9 8 7 6 5 4 3 2 1], 2, -1 -> [7 6 5 4 3 2 1]

func SubByteTest

func SubByteTest() (err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func SubStr

func SubStr(buf string, start_index int, size int) string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func TimeCropPerDay

func TimeCropPerDay(source time.Time) (target time.Time)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UintToStr

func UintToStr(value uint64) (str string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func Uniq

func Uniq(source []string) (target []string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixmicrotimeStrToIso

func UnixmicrotimeStrToIso(unixmicrotimeStr string, offset int64, flagNanoseconds bool) (iso string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// "1624120658256315" -> "2021-06-19 16:37:38.256315000" Obsolete: func Unixmicrotime_str2iso(unixmicrotime_str string) (iso string) {

func UnixmicrotimeToIso

func UnixmicrotimeToIso(unixmicrotime int64, offset int64, flagNanoseconds bool) (iso string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 1624120658256315 -> "2021-06-19 16:37:38.256315000" Obsolete: func Unixmicrotime2iso(unixmicrotime int64) (iso string) {

func UnixmicrotimeToUnixmillitime

func UnixmicrotimeToUnixmillitime(unixmicrotime int64) (unixmillitime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixmicrotimeToUnixnanotime

func UnixmicrotimeToUnixnanotime(unixmicrotime int64) (unixnanotime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixmillitimeToUnixmicrotime

func UnixmillitimeToUnixmicrotime(unixmillitime int64) (unixmicrotime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixmillitimeToUnixtime

func UnixmillitimeToUnixtime(unixmillitime int64) (unixtime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixnanotimeCropPerDay

func UnixnanotimeCropPerDay(unixnanotimeSource int64) (unixnanotimeTarget int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixnanotimePack

func UnixnanotimePack(pTime *Time) (unixnanotime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixnanotimeStrToIso

func UnixnanotimeStrToIso(unixnanotimeStr string, offset int64, flagNanoseconds bool) (iso string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// "1624120658256315911" -> "2021-06-19 16:37:38.256315911" Obsolete: func Unixnanotime_str2iso(unixnanotime_str string) (iso string) {

func UnixnanotimeToIso

func UnixnanotimeToIso(unixnanotime int64, offset int64, flagNanoseconds bool) (iso string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 1624120658256315911 -> "2021-06-19 16:37:38.256315911" Obsolete: func Unixnanotime2iso(unixnanotime int64) (iso string) {

func UnixnanotimeToUnixmicrotime

func UnixnanotimeToUnixmicrotime(unixnanotime int64) (unixmicrotime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixnanotimeUnpack

func UnixnanotimeUnpack(unixnanotime int64, pTime *Time)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UnixtimeStrToIso

func UnixtimeStrToIso(unixtimeStr string, offset int64, flagNanoseconds bool) (iso string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// "1624120658" -> "2021-06-19 16:37:38.000000000" Obsolete: func Unixtime_str2iso(unixtime_str string) (iso string) {

func UnixtimeToIso

func UnixtimeToIso(unixtime int64, offset int64, flagNanoseconds bool) (iso string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 1624120658 -> "2021-06-19 16:37:38.000000000" Obsolete: func Unixtime2iso(unixtime int64) (iso string) {

func UnixtimeToUnixmillitime

func UnixtimeToUnixmillitime(unixtime int64) (unixmillitime int64)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UrlAddParam

func UrlAddParam(url string, key string, value string) (urlNew string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func UrlAddSlash

func UrlAddSlash(url string) (urlNew string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

Types

type Currency

type Currency struct {
	Name                string
	Symbol              string
	CountDigitAfterDot  int
	CountCoinOfCurrency int
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func GetCurrency

func GetCurrency(currencyName string) (currency Currency, err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// *

  • @author Alexey Potehin <gnuplanet@gmail.com>, http://www.gnuplanet.online/doc/cv
  • @brief get currency
  • @param currencyName name of currency (ISO4217)
  • @return currency currency
  • @return err error

type Result

type Result struct {
	// contains filtered or unexported fields
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) Draw1

func (p *Result) Draw1() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) Draw2

func (p *Result) Draw2() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) Draw3

func (p *Result) Draw3() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetCurentFileName

func (p *Result) GetCurentFileName() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetCurentFunctionName

func (p *Result) GetCurentFunctionName() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetCurentLine

func (p *Result) GetCurentLine() int

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetErrMsg

func (p *Result) GetErrMsg() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetErrNum

func (p *Result) GetErrNum() int

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetParentFileName

func (p *Result) GetParentFileName() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetParentFunctionName

func (p *Result) GetParentFunctionName() string

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetParentLine

func (p *Result) GetParentLine() int

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) GetPlace

func (p *Result) GetPlace(stackPosition int) (functionName string, fileName string, line int)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) Init

func (p *Result) Init()

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) IsErr

func (p *Result) IsErr() bool

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) IsOk

func (p *Result) IsOk() bool

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) SetErr

func (p *Result) SetErr(err error)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) SetErrMsg

func (p *Result) SetErrMsg(errNum int, errMsg string)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

func (*Result) SetOk

func (p *Result) SetOk()

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

type Time

type Time struct {
	Year       int
	Month      int
	Day        int
	Hour       int
	Minute     int
	Second     int
	Nanosecond int
	WeekDay    int
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

Jump to

Keyboard shortcuts

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