Documentation ¶
Overview ¶
Package util
Package utils ¶
Package utils ¶
Package util ¶
Package `utils` provides convenience functions helper ¶
Package utils ¶
Copyright 2010 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in https://raw.githubusercontent.com/golang/go/master/LICENSE
Package utils ¶
Package utils ¶
Package utils ¶
Package utils
Index ¶
- func DebugPrint(v ...interface{})
- func DumpToString(v interface{}) string
- func GenerateRandomNumberString(n int) string
- func InArray(val interface{}, array interface{}) bool
- func IsEmptyValue(i interface{}) bool
- func IsSameType(src, dest interface{}) bool
- func ParseDuration(s string) (time.Duration, error)
- func ReadFileAsBytes(filePath string) ([]byte, error)
- func ReadPrivateKey(privateKeyData []byte) (privateKey *rsa.PrivateKey, err error)
- func ReadPrivateKeyFile(filepath string) (privateKey *rsa.PrivateKey, err error)
- func ReadPublicKeyByte(publicKeyData []byte) (publicKey *rsa.PublicKey, err error)
- func ReadPublicKeyFile(filePath string) (pubKey *rsa.PublicKey, err error)
- func StreamToByte(stream io.Reader) []byte
- func StreamToString(stream io.Reader) string
- func StringJoin(elems []string, sep, lastSep string) string
- func StringReplacer(msg string, replacers map[string]string) string
- func StringToDate(s string) time.Time
- func StringToDateE(s string) (time.Time, error)
- func StructExtractFieldValue(src interface{}, tag string) ([]string, []interface{}, error)
- func StructToBulkInsert(src interface{}, tag string) ([]string, []interface{}, []string, error)
- func StructToMap(src interface{}, tag string) (map[string]interface{}, error)
- func ToJSONByte(v interface{}) []byte
- func ToString(value interface{}) string
- func WriteFile(content []byte, filename string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomNumberString ¶
GenerateRandomNumberString generate random string number
func InArray ¶ added in v1.0.1
func InArray(val interface{}, array interface{}) bool
InArray check if an element is exist in the array
func IsSameType ¶
func IsSameType(src, dest interface{}) bool
IsSameType check type from source to destination
func ParseDuration ¶ added in v1.0.2
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w".
func ReadFileAsBytes ¶
ReadFileAsBytes function read file and return bytes
func ReadPrivateKey ¶
func ReadPrivateKey(privateKeyData []byte) (privateKey *rsa.PrivateKey, err error)
ReadPrivateKey function RSA Read private key from byte
func ReadPrivateKeyFile ¶
func ReadPrivateKeyFile(filepath string) (privateKey *rsa.PrivateKey, err error)
ReadPrivateKeyFile function RSA Read private key from file
func ReadPublicKeyByte ¶
ReadPublicKeyByte function rsa read public key from file
func ReadPublicKeyFile ¶
ReadPublicKeyFile function read file rsa public key
func StringJoin ¶
StringJoin concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.
func StringReplacer ¶
StringReplacer replace string contains
func StringToDate ¶
StringToDate parsing string date to time.time
func StringToDateE ¶
StringToDate parsing string date to time.time with error
func StructExtractFieldValue ¶
StructExtractFieldValue iterate struct to separate key field and value
func StructToBulkInsert ¶ added in v1.0.3
StructToBulkInsert extract struct slice tu bulk insert sql
func StructToMap ¶
ToMap converts a struct to a map using the struct's tags.
ToMap uses tags on struct fields to decide which fields to add to the returned map.
Types ¶
This section is empty.