helper

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeLayoutY                 = "2006"
	TimeLayoutYM                = "2006-01"
	TimeLayoutYMD               = "2006-01-02"
	TimeLayoutYMDHM             = "2006-01-02 15:04"
	TimeLayoutYMDHMS            = "2006-01-02 15:04:05"
	TimeLayoutHM                = "15:04"
	TimeLayoutMDYYYYHMMSSPM     = "1/2/2006 3:04:05 PM"
	TimeLayoutNoSepYYYYMMDDHHMM = "200601021504"
	TimeLayoutTextMD            = "January 2"
	TimeLayoutRFC3339Milli      = "2006-01-02T15:04:05.999Z07:00"
	TimeLayoutRFC3339           = "2006-01-02T15:04:05.999Z"
)
View Source
const Day = 86400
View Source
const Hour = 3600
View Source
const Minute = 60
View Source
const Month = 2592000
View Source
const Second = 1
View Source
const Week = 604800
View Source
const Year = 31104000

Variables

This section is empty.

Functions

func BasicAuth added in v0.8.35

func BasicAuth(username, password string) string

func BoolToInt added in v0.0.8

func BoolToInt(b bool) int8

func CSVToMap added in v0.0.8

func CSVToMap(reader *bytes.Buffer) ([]map[string]string, error)

func Call added in v0.3.3

func Call(ctx context.Context,
	method,
	url string,
	headers map[string]string,
	timeout time.Duration,
	payload interface{},
	cookies []*http.Cookie) ([]byte, http.Header, int, error)

Call helper for api calls TODO : make service and use debug service to

func CallXML added in v0.5.0

func CallXML(ctx context.Context,
	method,
	url string,
	headers map[string]string,
	timeout time.Duration,
	payload interface{},
	cookies []*http.Cookie) ([]byte, http.Header, int, error)

func ChunkSliceUint64 added in v0.0.8

func ChunkSliceUint64(slice []uint64, chunkSize int) [][]uint64

func ConvertUint64ToHex added in v0.0.8

func ConvertUint64ToHex(serialNumber uint64) string

func Copy added in v0.0.8

func Copy(src, dst string, bufferSize int64) error

func DBTransaction added in v0.0.8

func DBTransaction(ormService *beeorm.Engine, callback transaction) error

func EqualString added in v1.3.2

func EqualString(a, b []string) bool

func ExistsInDir

func ExistsInDir(filename, dir string) bool

func FileExistsInDir added in v0.0.8

func FileExistsInDir(filename, dir string) bool

func GetFileExtensionFromBase64Header added in v0.0.8

func GetFileExtensionFromBase64Header(base64Header string) (string, error)

func GetFirstDayOfNextMonth added in v1.0.41

func GetFirstDayOfNextMonth() time.Time

func GetLastDayOfThisMonth added in v1.0.41

func GetLastDayOfThisMonth() time.Time

func GetPhoneWithPlus added in v1.2.32

func GetPhoneWithPlus(mobile string) string

func GetTemplateDirectory added in v0.0.8

func GetTemplateDirectory() string

func GetTimeDifference added in v0.0.8

func GetTimeDifference(from, to time.Time) time.Duration

func GetTimeDifferenceHuman added in v0.0.8

func GetTimeDifferenceHuman(startDate, endDate time.Time) string

func GetTimeDifferenceHumanBySeconds added in v0.0.8

func GetTimeDifferenceHumanBySeconds(seconds float64) string

func GetTimestamp added in v0.0.8

func GetTimestamp(t *time.Time) int64

func GetWeekDay added in v0.0.8

func GetWeekDay(dateTime time.Time) uint8

func HasIntersectionInt added in v0.1.3

func HasIntersectionInt(a []int, b []int) bool

func HasIntersectionInt32 added in v0.1.3

func HasIntersectionInt32(a []int32, b []int32) bool

func HasIntersectionInt64 added in v0.1.3

func HasIntersectionInt64(a []int64, b []int64) bool

func HasIntersectionUInt32 added in v0.1.3

func HasIntersectionUInt32(a []uint32, b []uint32) bool

func HasIntersectionUInt64 added in v0.1.3

func HasIntersectionUInt64(a []uint64, b []uint64) bool

func Int32InArray added in v0.1.3

func Int32InArray(s int32, arr ...int32) bool

func Int64InArray added in v0.1.3

func Int64InArray(s int64, arr ...int64) bool

func IntInArray added in v0.1.3

func IntInArray(s int, arr ...int) bool

func IsValidEnum added in v0.0.8

func IsValidEnum(val string, enums map[string]string) bool

func Limit added in v0.0.8

func Limit(pager *beeorm.Pager) string

func SliceUint64Difference added in v0.0.8

func SliceUint64Difference(slice1 []uint64, slice2 []uint64) []uint64

func StringInArray added in v0.1.3

func StringInArray(s string, arr ...string) bool

func SubtractInt32Slice added in v0.1.7

func SubtractInt32Slice(a []int32, b []int32) []int32

func SubtractInt64Slice added in v0.1.7

func SubtractInt64Slice(a []int64, b []int64) []int64

func SubtractIntSlice added in v0.1.7

func SubtractIntSlice(a []int, b []int) []int

func SubtractUInt32Slice added in v0.1.7

func SubtractUInt32Slice(a []uint32, b []uint32) []uint32

func SubtractUInt64Slice added in v0.1.7

func SubtractUInt64Slice(a []uint64, b []uint64) []uint64

func SubtractUIntSlice added in v0.1.7

func SubtractUIntSlice(a []uint, b []uint) []uint

func ToFixed added in v1.2.79

func ToFixed(num float64, precision int) float64

func TruncateTime added in v0.8.54

func TruncateTime(in time.Time) time.Time

func UIn32tInArray added in v0.1.3

func UIn32tInArray(s uint32, arr ...uint32) bool

func UIn64tInArray added in v0.1.3

func UIn64tInArray(s uint64, arr ...uint64) bool

func UniqueInt added in v0.1.3

func UniqueInt(a []int) []int

func UniqueInt32 added in v0.1.3

func UniqueInt32(a []int32) []int32

func UniqueInt64 added in v0.1.3

func UniqueInt64(a []int64) []int64

func UniqueString added in v0.1.3

func UniqueString(a []string) []string

func UniqueUInt32 added in v0.1.3

func UniqueUInt32(a []uint32) []uint32

func UniqueUInt64 added in v0.1.3

func UniqueUInt64(a []uint64) []uint64

func ValidateAndParseTimeRange added in v0.0.8

func ValidateAndParseTimeRange(startsAt, endsAt, fromName string, startsAtGTENow bool) (*time.Time, *time.Time, error)

Types

type Coordinates added in v1.2.70

type Coordinates struct {
	Latitude  float64
	Longitude float64
}

func (Coordinates) DistanceInKm added in v1.2.70

func (origin Coordinates) DistanceInKm(destination Coordinates) float64

func (Coordinates) DistanceInMeters added in v1.2.71

func (origin Coordinates) DistanceInMeters(destination Coordinates) float64

type DTOPrice added in v1.2.16

type DTOPrice struct {
	Price             float64
	PriceString       string
	PriceWithCurrency string
}

func GetPriceDTO added in v1.2.16

func GetPriceDTO(priceValue float64, priceCurrencyISO4217, countryCodeAlpha2 string) *DTOPrice

type Price added in v0.0.8

type Price int64

func NewPrice added in v0.0.8

func NewPrice(amount float64) Price

func NewTotalPrice added in v0.0.8

func NewTotalPrice(amount float64, quantity uint64) Price

func (Price) Float added in v0.0.8

func (c Price) Float() float64

func (Price) String added in v0.0.8

func (c Price) String() string

func (Price) StringByLocale added in v1.0.59

func (c Price) StringByLocale(locale, inCurrency string) (string, error)

func (Price) StringWithCurrency added in v0.0.8

func (c Price) StringWithCurrency(currencySymbol string) string

func (Price) Units added in v0.0.8

func (c Price) Units() int64

type TimeDifference added in v0.0.8

type TimeDifference struct {
	Years, Months, Days, Hours, Minutes, Seconds int
}

func GetTimeDifferenceStruct added in v1.2.58

func GetTimeDifferenceStruct(from, to time.Time) *TimeDifference

type URLQueryPager added in v0.2.1

type URLQueryPager struct {
	// example = ?current_page=1&page_size=25
	CurrentPage int `binding:"min=1" form:"current_page"`
	PageSize    int `binding:"min=1" form:"page_size"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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