utils

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 14 Imported by: 0

README

utils

Utils is function helper for go project

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugPrint

func DebugPrint(v ...interface{})

DebugPrint for debug print on terminal

func DumpToString

func DumpToString(v interface{}) string

DumpToString interface to string

func GenerateRandomNumberString

func GenerateRandomNumberString(n int) string

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 IsEmptyValue

func IsEmptyValue(i interface{}) bool

IsEmptyValue func interface value checker

func IsSameType

func IsSameType(src, dest interface{}) bool

IsSameType check type from source to destination

func ParseDuration added in v1.0.2

func ParseDuration(s string) (time.Duration, error)

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

func ReadFileAsBytes(filePath string) ([]byte, error)

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

func ReadPublicKeyByte(publicKeyData []byte) (publicKey *rsa.PublicKey, err error)

ReadPublicKeyByte function rsa read public key from file

func ReadPublicKeyFile

func ReadPublicKeyFile(filePath string) (pubKey *rsa.PublicKey, err error)

ReadPublicKeyFile function read file rsa public key

func StreamToByte

func StreamToByte(stream io.Reader) []byte

StreamToByte cast

func StreamToString

func StreamToString(stream io.Reader) string

StreamToString cast

func StringJoin

func StringJoin(elems []string, sep, lastSep string) string

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

func StringReplacer(msg string, replacers map[string]string) string

StringReplacer replace string contains

func StringToDate

func StringToDate(s string) time.Time

StringToDate parsing string date to time.time

func StringToDateE

func StringToDateE(s string) (time.Time, error)

StringToDate parsing string date to time.time with error

func StructExtractFieldValue

func StructExtractFieldValue(src interface{}, tag string) ([]string, []interface{}, error)

StructExtractFieldValue iterate struct to separate key field and value

func StructToBulkInsert added in v1.0.3

func StructToBulkInsert(src interface{}, tag string) ([]string, []interface{}, []string, error)

StructToBulkInsert extract struct slice tu bulk insert sql

func StructToMap

func StructToMap(src interface{}, tag string) (map[string]interface{}, error)

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.

func ToJSONByte

func ToJSONByte(v interface{}) []byte

Data To json Bytes

func ToString

func ToString(value interface{}) string

ToString converts a value to string.

func WriteFile

func WriteFile(content []byte, filename string) (err error)

WriteFile function write file

Types

This section is empty.

Jump to

Keyboard shortcuts

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