Documentation ¶
Overview ¶
Package util implements a set of util functions.
Index ¶
- func Base64Encode(data []byte) string
- func CheckFileExists(filename string) bool
- func Contains(slice []string, value string, caseInsensitive bool) bool
- func CreateRandomString() string
- func Debug(title, message string)
- func FormatTest(funcName, got, expected string) string
- func GetMD5(data interface{}, base64Encode bool) string
- func GetMapKey(m map[string]string, key string, caseInsensitive bool) string
- func GetMapValue(m map[string]string, key string, caseInsensitive bool) string
- func GetSha256(data interface{}) string
- func GetURIPath(uri string) string
- func GetURL(protocol, host, uriPath string, params map[string]string) string
- func GuessMimeType(s string) string
- func HmacSha256Hex(key, message string) string
- func HomeDir() (string, error)
- func HostToURL(host, protocol string) string
- func MapContains(m map[string]string, compareFunc func(string, string) bool) bool
- func MapKeyToLower(m map[string]string)
- func SliceToLower(slice []string)
- func TempFile(content []byte, dir, prefix string) (*os.File, error)
- func TempFileWithSize(fileSize int64) (*os.File, error)
- func TimeStringToRFC1123(str string) string
- func TimeToUTCString(t time.Time) string
- func ToCanonicalHeaderString(headerMap map[string]string) string
- func ToCanonicalQueryString(params map[string]string) string
- func ToJson(i interface{}, keys ...string) ([]byte, error)
- func ToMap(i interface{}, keys ...string) (map[string]interface{}, error)
- func URIEncodeExceptSlash(uri string) string
- func URLEncode(str string) string
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Encode ¶
Base64Encode gets base64 encoded string from data.
func CheckFileExists ¶
CheckFileExists checks if specified file exists.
func Contains ¶
Contains determines whether a string slice contains a certain value. Ignore case when comparing if case insensitive.
func FormatTest ¶
FormatTest returns a formatted string for unit test.
func GetMD5 ¶
GetMD5 gets the MD5 value from data. Param base64Encode determines whether use Base64Encode meanwhile.
func GetMapKey ¶
GetMapKey returns the key of the map for a certain value. Ignore case when comparing if case insensitive.
func GetMapValue ¶
GetMapValue returns the value of the map for a certain key. Ignore case when comparing if case insensitive.
func GuessMimeType ¶
GuessMimeType gets the MIME Type of a suffix string.
func HmacSha256Hex ¶
HmacSha256Hex returns a encrypted string.
func MapContains ¶
MapContains determines whether the string map contains a uncertain value. The result is determined by compare function.
func MapKeyToLower ¶
MapKeyToLower transforms each item of a map to lowercase.
func SliceToLower ¶
func SliceToLower(slice []string)
SliceToLower transforms each item of a slice to lowercase.
func TempFileWithSize ¶
TempFileWithSize generates a temp file with specified size.
func TimeStringToRFC1123 ¶
TimeStringToRFC1123 returns a formatted string of `time.RFC1123` format.
func TimeToUTCString ¶
TimeToUTCString returns a utc string of a time instance.
func ToCanonicalHeaderString ¶
ToCanonicalHeaderString returns the canonicalized string.
func ToCanonicalQueryString ¶
ToCanonicalQueryString returns the canonicalized query string.
func URIEncodeExceptSlash ¶
URIEncodeExceptSlash encodes all characters of a string except the slash character.
Types ¶
This section is empty.
Notes ¶
Bugs ¶
see https://github.com/golang/go/issues/4013 use %20 instead of the + character for encoding a space