common

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChecksumEthereumAddress

func ChecksumEthereumAddress(addr string) string

Return checksummed ethereum address.

func ConnectArray

func ConnectArray(strList []string, connector string) string

Connect the items in an array with "connector".

func ContainAnyOfStrs added in v0.1.1

func ContainAnyOfStrs(longStr string, targets []string) bool

func ContainInArray

func ContainInArray[T comparable](target T, targetArray []T) bool

func ContainPhoneticSymbol added in v0.1.2

func ContainPhoneticSymbol(longStr string, target string) bool

func CreateKey added in v0.0.4

func CreateKey() (privateKey string, address string)

Create a pair of private key and address.

func FindBytesBetween added in v0.1.1

func FindBytesBetween(fullBytes []byte, bytesBefore []byte, bytesAfter []byte) (target [][]byte)

find all []byte between "bytesBefore" and "bytesAfter"

func FindStringBetween added in v0.1.1

func FindStringBetween(fullStr string, strBefore string, strAfter string) (target []string)

find all string between "strBefore" and "strAfter"

func FormatJson

func FormatJson(obj any) string

func FormatJsonByte

func FormatJsonByte(obj any) []byte

func GetMonthStart

func GetMonthStart(location string) time.Time

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func GetStringHash

func GetStringHash(input string) string

For example: "TraderJoeSupplyEvent(address,address,uint256,address)". Space must not be included.

func GetTimeByStr

func GetTimeByStr(str string, location string) time.Time

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func GetTimeRangeByType

func GetTimeRangeByType(t string, location string) (start int64, end int64)

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func GetTodayStart

func GetTodayStart(location string) time.Time

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func GetWeekStart

func GetWeekStart(location string) time.Time

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func GetYearStart

func GetYearStart(location string) time.Time

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func PhoneticSymbolToCommonLetter added in v0.1.2

func PhoneticSymbolToCommonLetter(str string) string

func PrettifyJson

func PrettifyJson(raw string) string

func PrettyJsonPrintln

func PrettyJsonPrintln(obj any)

func ReadCsv

func ReadCsv(filePath string) ([][]string, error)

FilePath e.g. "./example.csv".

func ReadJsonSlice

func ReadJsonSlice(path string) ([]string, error)

func RemoveFromArray added in v0.1.1

func RemoveFromArray[T comparable](targetArray []T, targetRem T) []T

func RemoveFromString added in v0.1.1

func RemoveFromString(targetStr string, targetRem string) string

func RemoveRepetitionInArray

func RemoveRepetitionInArray[T comparable](targetArray []T) []T

func Restart

func Restart(functionToRecover func(), functionName string)

Recover from panic and restart.

func RestartAndSleep added in v0.0.3

func RestartAndSleep(functionToRecover func(), functionName string, sleepTime time.Duration)

Recover from panic and restart after waiting for a while.

func SendMail added in v0.0.2

func SendMail(senderInfo EmailSenderStruct, receivers []string, subject string, body string) (err error)

func SeperateIntoArray added in v0.1.1

func SeperateIntoArray(targetStr string, seperateBy string) (res []string)

Seperate a string into an array, the seperater will be deleted.

func SimpleMarshal

func SimpleMarshal(obj any) []byte

func SimpleStringify

func SimpleStringify(obj any) string

func Stringify

func Stringify(obj any) string

func TimeFormat

func TimeFormat(timestamp int64, location string) string

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func TimeFormatTime

func TimeFormatTime(timestamp int64, location string) time.Time

If location is "" or "UTC", use UTC time. If location is "Local", use local time. Location can also be "America/New_York", "Asia/Shanghai", etc.

func TimeNowString

func TimeNowString() string

func TimestampNow

func TimestampNow() int

func ToCommonLetter added in v0.1.1

func ToCommonLetter(str string) string

func WriteNewCsv

func WriteNewCsv(filePath string, title []string, text [][]string) error

If file exist, will cover the old file.

func WriteToCsv

func WriteToCsv(filePath string, title []string, text []string) error

Write to csv line by line.

Types

type EmailSenderStruct added in v0.0.3

type EmailSenderStruct struct {
	Sender         string `json:"sender"`
	SenderPassword string `json:"senderPassword"`
	SenderToken    string `json:"senderToken"`
	SenderNickname string `json:"senderNickname"`
	Host           string `json:"host"`
	Port           string `json:"port"`
}

Jump to

Keyboard shortcuts

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