utils

package module
v0.3.64 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 18 Imported by: 0

README

mm-go-utilities

Documentation

Index

Constants

View Source
const (
	STRING_FORMAT_DATE_LONG  string = "2006-01-02 15:04:05"
	STRING_FORMAT_DATE_SHORT string = "2006-01-02"
	STRING_FORMAT_MONTH_YEAR string = "2006-01"
	STRING_FORMAT_YEAR       string = "2006"
)
View Source
const (
	DEFAULT_HEADER_STYLE = `` /* 293-byte string literal not displayed */
	DEFAULT_VALUE_STYLE  = `` /* 281-byte string literal not displayed */
)

Variables

View Source
var (
	IGNORE_FIELDS = []string{"state", "sizeCache", "unknownFields"}
)
View Source
var MAP_EXCEL_COLUMN_INDEX = map[int]string{}/* 234 elements not displayed */
View Source
var REMOVE_PATHS = []string{"cmd/main", "cmd\\main"}
View Source
var TYPE_GUID reflect.Type = nil
View Source
var TYPE_GUID_POINTER reflect.Type = nil
View Source
var TYPE_SQL_ERROR reflect.Type = nil
View Source
var TYPE_TIME reflect.Type = nil
View Source
var TYPE_TIMESTAMP reflect.Type = nil
View Source
var TYPE_TIMESTAMP_POINTER reflect.Type = nil
View Source
var TYPE_TIME_POINTER reflect.Type = nil

Functions

func AnyContains added in v0.0.5

func AnyContains[T any](finder T, sources ...T) bool

AnyContains checks if the given slice contains the given element. It takes a variable number of arguments of any type. The first argument is the element to be searched for, and the rest are the elements in the slice. It returns true if the element is found in the slice, false otherwise.

func BoolToInt added in v0.1.0

func BoolToInt(v bool) int

BoolToInt returns 1 if `v` is true, otherwise returns 0.

func ByteArrayToBase64

func ByteArrayToBase64(bytes []byte) string

ByteArrayToBase64 function takes a byte slice and returns its base64 encoded string representation

func CheckPasswordHash added in v0.0.4

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash checks whether a given password string matches a given hash string generated by the HashPassword function. It takes the following arguments: - password: the password string to check - hash: the hash string to compare against The function returns true if the password matches the hash, or false otherwise.

func CloneFields

func CloneFields[IN comparable, OUT comparable](input IN, output OUT, ignoreFields ...string) OUT

CloneFields clones values from input to output based on the field names of output type ignores fields listed in ignoreFields. It returns the cloned output.

func ComparableContains added in v0.0.5

func ComparableContains[T comparable](finder T, sources ...T) bool

ComparableContains checks if a given value of type T is contained within the provided slice of values of type T. It returns true if the value is found and false otherwise. The type parameter T is constrained to the comparable type, which means that values of type T must be comparable using the == operator. This function is optimized for performance and type safety by avoiding the use of reflection or any other additional checks.

func DecodeBase64 added in v0.0.9

func DecodeBase64(s string) (string, error)

DecodeBase64 function takes a base64 encoded string input and returns the decoded string and any errors

func Distinct added in v0.3.61

func Distinct[T comparable](sources []*T) []*T

Distinct takes a slice of pointers to comparable values of type T and returns a new slice with distinct elements.

func EncodeBase64 added in v0.0.9

func EncodeBase64(s string) string

EncodeBase64 function takes a string input and returns its base64 encoded string representation

func Execute added in v0.3.0

func Execute[R, T any](db IGormDB[R, T], controller string, action string, claims IClaims, request interface{}, result interface{}) error

func ExecuteId added in v0.3.0

func ExecuteId[R ISqlRow, T any](db IGormDB[R, T], controller string, action string, claims IClaims, id interface{}, result interface{}) error

func ExecuteIdMultipleResult added in v0.3.0

func ExecuteIdMultipleResult[R, T any](db IGormDB[R, T], controller string, action string, claims IClaims, id interface{}, results ...interface{}) error

func ExecuteMultipleResult added in v0.3.0

func ExecuteMultipleResult[R, T any](db IGormDB[R, T], controller string, action string, claims IClaims, request interface{}, results ...interface{}) error

func ExportXlsx added in v0.3.55

func ExportXlsx[T any](f IExcel, fields []IExportField, sheetName string, startRow, startColumn int, data []T, handleCellValue func(string, T) interface{}, prefix string) ([]byte, string, error)

ExportXlsx is a generic function that exports data to an Excel file. It accepts an IExcel interface for writing to Excel, a slice of IExportField that specifies the fields to export, a sheetName string, startRow and startColumn integers, a slice of data of type T, a handleCellValue function that formats cell values, and a prefix string for the file name. The function writes the data to the specified sheet in the Excel file, saves the file, and returns the file bytes, file name and error (if any). If the specified sheetName does not exist in the Excel file, a new sheet with the specified name is created. The function also sets the column width of the sheet based on the number of fields. The handleCellValue function is called for each cell in the exported data and can be used to format the cell value. The prefix string is used to generate a unique file name for the exported file.

func FilterPagination added in v0.3.0

func FilterPagination[R, T any](db IGormDB[R, T], controller string, action string, claims IClaims, filters interface{}, paging interface{}, results ...interface{}) error

func Find added in v0.1.6

func Find[T any](sources []T, predicate func(T) bool) T

Find searches the input slice for the first element that matches the given predicate, and returns that element. If no element matches the predicate, it returns the zero value of type T.

func FindLast added in v0.1.6

func FindLast[T any](sources []T, predicate func(T) bool) T

FindLast searches the input slice for the last element that matches the given predicate, and returns that element. If no element matches the predicate, it returns the zero value of type T.

func FindName added in v0.3.52

func FindName[T comparable](claims IClaims, models ...*FindNameModel[T])

func FindNames added in v0.3.45

func FindNames[T comparable](claims IClaims, modules []IName[T], ids [][]*T, completeds []func([]INameItem[T]))

func FindQuery added in v0.0.3

func FindQuery(controller string, action string) string

FindQuery reads an XML file containing controller and action data, and returns the query string associated with a given controller and action. It takes the following arguments: - controller: the name of the XML file (without the extension) to be read - action: the name of the action to find in the XML file The function returns the query string associated with the given controller and action, or an empty string if the XML file cannot be read or the controller and action cannot be found.

func FindQueryWithinParam added in v0.0.3

func FindQueryWithinParam(controller string, action string, queryParam string) string

FindQueryWithinParam reads an XML file containing controller and action data, replaces a placeholder string in the query string with a given parameter value, and returns the resulting query string. It takes the following arguments: - controller: the name of the XML file (without the extension) to be read - action: the name of the action to find in the XML file - queryParam: the value to replace the "[QUERY_PARAMS]" placeholder string with The function returns the resulting query string, or an empty string if the XML file cannot be read or the controller and action cannot be found.

func FindQueryWithinParamAndUser added in v0.0.7

func FindQueryWithinParamAndUser[T any](controller string, action string, queryParam string, user T, replaceUserFunc func(string, T) string) string

FindQueryWithinParamAndUser reads an XML file containing controller and action data, replaces a placeholder string in the query string with a given parameter value, replaces another placeholder string in the resulting string with a given user object, and returns the resulting query string. It takes the following arguments:

  • controller: the name of the XML file (without the extension) to be read
  • action: the name of the action to find in the XML file
  • queryParam: the value to replace the "[QUERY_PARAMS]" placeholder string with
  • user: an object representing the user to replace the "[USER]" placeholder string with
  • replaceUserFunc: a function that takes a string and a user object, and returns the string with the "[USER]" placeholder string replaced with the user object

The function returns the resulting query string, or an empty string if the XML file cannot be read or the controller and action cannot be found.

func FindQueryWithinUser added in v0.0.7

func FindQueryWithinUser[T any](controller string, action string, user T, replaceUserFunc func(string, T) string) string

FindQueryWithinUser reads an XML file containing controller and action data, replaces another placeholder string in the query string with a given user object, and returns the resulting query string. It takes the following arguments:

  • controller: the name of the XML file (without the extension) to be read
  • action: the name of the action to find in the XML file
  • user: an object representing the user to replace the "[USER]" placeholder string with
  • replaceUserFunc: a function that takes a string and a user object, and returns the string with the "[USER]" placeholder string replaced with the user object

The function returns the resulting query string, or an empty string if the XML file cannot be read or the controller and action cannot be found.

func HandleGrpcError added in v0.1.1

func HandleGrpcError(err error) error

HandleGrpcError handles gRPC errors by returning a new error object that contains the gRPC error message. If the provided error is not a gRPC error, the function simply returns the original error.

func HandleSqlError added in v0.1.3

func HandleSqlError(err error) error

HandleSqlError handles SQL errors by returning a new error object that contains the SQL error message. If the provided error is not of type mssql.Error, the function simply returns the original error.

func HashPassword added in v0.0.4

func HashPassword(password string) (string, error)

HashPassword generates a bcrypt hash for a given password string with a cost of 2^14 iterations (recommended as of 2021). It takes the following argument: - password: the password string to hash The function returns the resulting hash string, or an error if the hashing operation fails.

func IIF added in v0.1.0

func IIF[T any](v bool, trueVal T, falseVal T) T

IIF returns `trueVal` if `v` is true, otherwise returns `falseVal`. It is a generic function and works with any data type.

func JsonToObject added in v0.0.5

func JsonToObject[T any](jsonString string, value T) error

JsonToObject is a generic function that parses a JSON string and unmarshals it into a value of type T. The JSON string is passed in as the first argument, and the value to unmarshal into is passed in as the second argument. The function returns an error if the JSON string cannot be unmarshaled into the value.

func Md5Hash

func Md5Hash(input string) (ouput string)

Md5Hash function takes a string input and returns its MD5 hash as a hexadecimal string

func NewValidateHttpError added in v0.3.62

func NewValidateHttpError(err error) error

func ObjectToJson added in v0.0.5

func ObjectToJson[T any](object T, value *string) error

ObjectToJson is a generic function that marshals a value of type T into a JSON string. The value to marshal is passed in as the first argument, and a pointer to a string variable to store the result is passed in as the second argument. The function returns an error if the value cannot be marshaled into a JSON string.

func RemoveAt

func RemoveAt[T any](sources []T, index int) []T

RemoveAt remove an element

func RunChannel added in v0.3.45

func RunChannel(callBacks ...func())

func RunFuncThreads added in v0.3.48

func RunFuncThreads(sources []Function, maxChannel int)

func RunSync added in v0.3.45

func RunSync(callBacks ...func())

func RunValueIndexThreads added in v0.3.58

func RunValueIndexThreads[T any](sources []T, maxChannel int, completedFunc func(v IThreadIndex[T]) error) []error

RunValueIndexThreads is a function that receives a slice of elements of any type 'T', and an integer 'maxChannel' that represents the number of goroutines to be executed simultaneously. It also takes a function 'completedFunc' that receives an object of type IThreadIndex[T] and returns an error, which is the function that will be executed for each element.

The function iterates through the slice, and for each element, it creates an object of type 'threadIndex[T]' that holds the index and data of the element, and sends it to the channel 'ch'. Then it creates 'maxChannel' goroutines that read from the channel 'ch', and for each element, execute the function 'completedFunc' passing the element, and send the returned error to the channel 'chErrs'.

After all elements are processed, the function closes the channel 'ch' and waits for all goroutines to finish with the WaitGroup 'wg'. Finally, it reads from the channel 'chErrs' to get the errors returned by the function 'completedFunc' for each element, and returns them in a slice of errors.

The function returns a slice of errors, where each index corresponds to the index of the element in the input slice, and the value is the error returned by the function 'completedFunc' for that element.

func RunValueThreads added in v0.3.48

func RunValueThreads[T any](sources []T, maxChannel int, completedFunc func(T) error) []error

func Safe

func Safe(value string) string

Safe sanitizes a given string to be used in a SQL query as a value. It replaces any occurrences of the single quote character with two single quote characters to escape them. The sanitized string is returned.

func SafeColumnName

func SafeColumnName(value string) string

SafeColumnName sanitizes a given string to be used as a column name in a database. It removes any characters that are not letters, numbers, underscores, or dollar signs. The sanitized string is returned.

func Select added in v0.1.6

func Select[T any, V any](sources []T, predicate func(T) V) []V

Select applies the given predicate function to each element in the input slice, and returns a new slice containing the results of the predicate function applied to each element.

func SelectIndex added in v0.3.58

func SelectIndex[T any, V any](sources []T, predicate func(int, T) V) []V

Select applies the given predicate function to each element in the input slice, and returns a new slice containing the results of the predicate function applied to each element.

func SetIsDevelopment added in v0.3.0

func SetIsDevelopment(isDev bool)

func SetType added in v0.3.42

func SetType(time reflect.Type, timePtr reflect.Type, stamp reflect.Type, stampPtr reflect.Type, sqlError reflect.Type, uuid reflect.Type, uuidPtr reflect.Type)

func StringFormat added in v0.1.1

func StringFormat(source string, params ...interface{}) string

StringFormat formats the given string by replacing placeholders with the corresponding values of the parameters. Placeholders are in the format of {i}, where i is the index of the parameter in the list.

func TimeStampToTime

func TimeStampToTime(timestamp timestamppb.Timestamp) time.Time

TimeStampToTime converts a timestamppb.Timestamp value to a time.Time value

func TimeStampToTimePointer

func TimeStampToTimePointer(timestamp *timestamppb.Timestamp) *time.Time

TimeStampToTimePointer converts a pointer to timestamppb.Timestamp value to a pointer to time.Time value

func TimeToTimeStamp

func TimeToTimeStamp(value time.Time) timestamppb.Timestamp

TimeToTimeStamp converts a time.Time value to a timestamppb.Timestamp value

func TimeToTimeStampPointer added in v0.0.5

func TimeToTimeStampPointer(value *time.Time) *timestamppb.Timestamp

TimeToTimeStampPointer converts a pointer to time.Time value to a pointer to timestamppb.Timestamp value

func ToFormat

func ToFormat(value *time.Time, format string) string

ToFormat converts a time.Time value to a string using the given format

func ToInterfaceSlice

func ToInterfaceSlice(s reflect.Value) []interface{}

ToInterfaceSlice converts a slice of any type to a slice of interface{}. It takes a reflect.Value as input and returns a []interface{}. If the input is nil, it returns an empty []interface{}. It iterates through the slice and adds each element to the result slice as an interface{}. If an element is a pointer, it dereferences the pointer and adds the underlying value as an interface{}.

func ToLongTime

func ToLongTime(value *time.Time) string

ToLongTime converts a time.Time value to a string in long time format

func ToSqlScript

func ToSqlScript(value interface{}, tableName string, ignoreFields ...string) string

ToSqlScript converts a struct or slice of structs to a SQL script that can be used to declare and insert data into a SQL Server table.

The `value` parameter can be either a struct or a slice of structs. If it's a struct, a script to declare the table will be created and then a script to insert the data into that table. If it's a slice of structs, a script to declare the table will be created only once and then a script to insert each struct in the slice into that table will be created.

The `tableName` parameter specifies the name of the SQL Server table that the data will be inserted into.

The `ignoreFields` parameter is an optional list of struct field names to exclude from the generated script.

func Where added in v0.1.6

func Where[T any](sources []T, conditional func(T) bool) []T

Where filters the input slice by applying the given conditional function to each element, and returns a new slice containing only the elements for which the conditional function returns true.

func WriteDataIntoFile

func WriteDataIntoFile[T any](f IExcel, fields []IExportField, sheetName string, startRow, startColumn int, data []T, handleCellValue func(string, T) interface{})

WriteDataIntoFile writes the data contained in a slice of structs to an xlsx file. The headers are specified in the header argument. The data is written starting at the specified startRow and startColumn. The style is used to style the entire range of the data (excluding headers). The handleCellValue function is called for each cell in the data range and should return the cell value.

Types

type Finalware added in v0.2.2

type Finalware = func()

type FinalwareV1 added in v0.2.2

type FinalwareV1[P1 any] func(P1)

type FinalwareV2 added in v0.2.2

type FinalwareV2[P1 any, P2 any] func(P1, P2)

type FinalwareV3 added in v0.2.2

type FinalwareV3[P1 any, P2 any, P3 any] func(P1, P2, P3)

type FinalwareV4 added in v0.2.2

type FinalwareV4[P1 any, P2 any, P3 any, P4 any] func(P1, P2, P3, P4)

type FindNameModel added in v0.3.45

type FindNameModel[T comparable] struct {
	Id               *T
	Ids              []*T
	OnCompleted      func(INameItem[T])
	OnCompletedSlice func([]INameItem[T])
	Module           IName[T]
}

type Function added in v0.3.48

type Function func()

type IClaims added in v0.3.0

type IClaims interface {
	GetId() int64
	GetClientId() int64
	GetUnitId() int64
	GetUsername() string
	GetEmail() string
	GetFullname() string
	GetPhone() string
	GetIsAdmin() bool
	GetIsSystem() bool
	GetLanguage() string
	GetIsBaseLanguage() bool
}

type IDB added in v0.3.3

type IDB[R any] interface {
	Rows() (R, error)
	ScanRows(rows R, dest interface{}) error
}

type IExcel added in v0.3.42

type IExcel interface {
	SaveAs(name string) error
	SetSheetName(oldName, newName string)
	NewStyle(style string) (int, error)
	SetCellValue(sheet, axis string, value interface{})
	SetCellStyle(sheet, hcell, vcell string, styleID int)
	SetColWidth(sheetName string, startCol string, endCol string, width float64)
	SetActiveSheet(index int)
	GetSheetIndex(name string) int
	NewSheet(name string) int
}

type IExportField added in v0.3.54

type IExportField interface {
	GetName() string
	GetHeader() string
}

type IGormDB added in v0.3.1

type IGormDB[R, T any] interface {
	Rows() (R, error)
	Raw(sql string, values ...interface{}) T
	ScanRows(rows R, dest interface{}) error
}

type IListenerV1 added in v0.0.8

type IListenerV1[P1 any] interface {
	Push(*func(P1))
	Pop(*func(P1))
	Invoke(P1, ...FinalwareV1[P1])
	InvokeAll(P1, ...Finalware)
}

func NewListenerV1 added in v0.0.8

func NewListenerV1[P1 any]() IListenerV1[P1]

NewListenerV1 returns a new instance of ListenerV1 with initial values of p1 and p2.

type IListenerV2 added in v0.0.8

type IListenerV2[P1 any, P2 any] interface {
	Push(*func(P1, P2))
	Pop(*func(P1, P2))
	Invoke(P1, P2, ...FinalwareV2[P1, P2])
	InvokeAll(P1, P2, ...Finalware)
}

func NewListenerV2 added in v0.0.8

func NewListenerV2[P1 any, P2 any]() IListenerV2[P1, P2]

NewListenerV2 returns a new instance of ListenerV2 with initial values of p1 and p2.

type IListenerV3 added in v0.1.1

type IListenerV3[P1 any, P2 any, P3 any] interface {
	Push(*func(P1, P2, P3))
	Pop(*func(P1, P2, P3))
	Invoke(P1, P2, P3, ...FinalwareV3[P1, P2, P3])
	InvokeAll(P1, P2, P3, ...Finalware)
}

func NewListenerV3 added in v0.1.1

func NewListenerV3[P1 any, P2 any, P3 any]() IListenerV3[P1, P2, P3]

NewListenerV3 returns a new instance of ListenerV3 with initial values of p1 and p2.

type IListenerV4 added in v0.2.1

type IListenerV4[P1 any, P2 any, P3 any, P4 any] interface {
	Push(*func(P1, P2, P3, P4))
	Pop(*func(P1, P2, P3, P4))
	Invoke(P1, P2, P3, P4, ...FinalwareV4[P1, P2, P3, P4])
	InvokeAll(P1, P2, P3, P4, ...Finalware)
}

func NewListenerV4 added in v0.2.2

func NewListenerV4[P1 any, P2 any, P3 any, P4 any]() IListenerV4[P1, P2, P3, P4]

NewListenerV4 returns a new instance of ListenerV3 with initial values of p1 and p2.

type IName added in v0.3.45

type IName[T comparable] interface {
	InternalFindItemName(id T, claims IClaims) INameItem[T]
	InternalFindItemNameByListID(ids []*T, claims IClaims) []INameItem[T]
}

type INameItem added in v0.3.50

type INameItem[T comparable] interface {
	GetId() T
	GetName() *string
	GetCode() *string
}

type ISqlError added in v0.3.42

type ISqlError interface {
	SQLErrorMessage() string
}

type ISqlRow added in v0.3.4

type ISqlRow interface {
	Close() error
	Next() bool
	NextResultSet() bool
}

type IThreadIndex added in v0.3.58

type IThreadIndex[T any] interface {
	GetIndex() int
	GetData() T
}

type IValidateError added in v0.3.62

type IValidateError interface {
	Error() string
	Status() int
	Field() string
}

type Listener added in v0.2.1

type Listener struct {
	// contains filtered or unexported fields
}

func NewListener added in v0.2.2

func NewListener() *Listener

NewListenerV1 returns a new instance of ListenerV1 with initial values of p1 and p2.

func (*Listener) Invoke added in v0.2.1

func (l *Listener) Invoke(args ...interface{})

func (*Listener) Pop added in v0.2.1

func (l *Listener) Pop(event func(args ...interface{}))

func (*Listener) Push added in v0.2.1

func (l *Listener) Push(event func(args ...interface{}))

type ListenerV1 added in v0.0.8

type ListenerV1[P1 any] struct {
	// contains filtered or unexported fields
}

ListenerV1 is a generic event listener for one parameter events. P1 can be any type of parameters

func (*ListenerV1[P1]) Invoke added in v0.0.8

func (l *ListenerV1[P1]) Invoke(a P1, wares ...FinalwareV1[P1])

Invoke calls all the events with the provided parameter.

func (*ListenerV1[P1]) InvokeAll added in v0.2.3

func (l *ListenerV1[P1]) InvokeAll(a P1, wares ...Finalware)

Invoke calls all the events with the provided parameter.

func (*ListenerV1[P1]) Pop added in v0.0.8

func (l *ListenerV1[P1]) Pop(event *func(a P1))

Pop removes an event from the listener.

func (*ListenerV1[P1]) Push added in v0.0.8

func (l *ListenerV1[P1]) Push(event *func(a P1))

Push adds an event to the listener.

type ListenerV2 added in v0.0.8

type ListenerV2[P1 any, P2 any] struct {
	// contains filtered or unexported fields
}

ListenerV2 is a generic type that represents an event listener that accepts two parameters P1 and P2 can be any type of parameters

func (*ListenerV2[P1, P2]) Invoke added in v0.0.8

func (l *ListenerV2[P1, P2]) Invoke(a P1, b P2, wares ...FinalwareV2[P1, P2])

Invoke calls all the events in the events slice and passes a and b as parameters to them

func (*ListenerV2[P1, P2]) InvokeAll added in v0.2.3

func (l *ListenerV2[P1, P2]) InvokeAll(a P1, b P2, wares ...Finalware)

Invoke calls all the events with the provided parameter.

func (*ListenerV2[P1, P2]) Pop added in v0.0.8

func (l *ListenerV2[P1, P2]) Pop(event *func(a P1, b P2))

Pop removes an event from the events slice

func (*ListenerV2[P1, P2]) Push added in v0.0.8

func (l *ListenerV2[P1, P2]) Push(event *func(a P1, b P2))

Push adds an event to the events slice

type ListenerV3 added in v0.1.1

type ListenerV3[P1 any, P2 any, P3 any] struct {
	// contains filtered or unexported fields
}

ListenerV3 is a generic type that represents an event listener that accepts two parameters P1 and P2 and P3 can be any type of parameters

func (*ListenerV3[P1, P2, P3]) Invoke added in v0.1.1

func (l *ListenerV3[P1, P2, P3]) Invoke(a P1, b P2, c P3, wares ...FinalwareV3[P1, P2, P3])

Invoke calls all the events in the listener's event queue with the given parameters.

func (*ListenerV3[P1, P2, P3]) InvokeAll added in v0.2.3

func (l *ListenerV3[P1, P2, P3]) InvokeAll(a P1, b P2, c P3, wares ...Finalware)

Invoke calls all the events with the provided parameter.

func (*ListenerV3[P1, P2, P3]) Pop added in v0.1.1

func (l *ListenerV3[P1, P2, P3]) Pop(event *func(a P1, b P2, c P3))

Pop removes an event from the listener's event queue.

func (*ListenerV3[P1, P2, P3]) Push added in v0.1.1

func (l *ListenerV3[P1, P2, P3]) Push(event *func(a P1, b P2, c P3))

Push adds an event to the listener's event queue.

type ListenerV4 added in v0.2.1

type ListenerV4[P1 any, P2 any, P3 any, P4 any] struct {
	// contains filtered or unexported fields
}

ListenerV3 is a generic type that represents an event listener that accepts two parameters P1 and P2 and P3 can be any type of parameters

func (*ListenerV4[P1, P2, P3, P4]) Invoke added in v0.2.1

func (l *ListenerV4[P1, P2, P3, P4]) Invoke(a P1, b P2, c P3, d P4, wares ...FinalwareV4[P1, P2, P3, P4])

Invoke calls all events in the event slice with the given parameters

func (*ListenerV4[P1, P2, P3, P4]) InvokeAll added in v0.2.3

func (l *ListenerV4[P1, P2, P3, P4]) InvokeAll(a P1, b P2, c P3, d P4, wares ...Finalware)

Invoke calls all the events with the provided parameter.

func (*ListenerV4[P1, P2, P3, P4]) Pop added in v0.2.1

func (l *ListenerV4[P1, P2, P3, P4]) Pop(event *func(a P1, b P2, c P3, d P4))

Pop removes an event from the event slice

func (*ListenerV4[P1, P2, P3, P4]) Push added in v0.2.1

func (l *ListenerV4[P1, P2, P3, P4]) Push(event *func(a P1, b P2, c P3, d P4))

Push adds an event to the event slice

type NameItem added in v0.3.50

type NameItem[T any] struct {
	Id   T
	Name *string
	Code *string
}

func (*NameItem[T]) GetCode added in v0.3.64

func (e *NameItem[T]) GetCode() *string

func (*NameItem[T]) GetId added in v0.3.50

func (e *NameItem[T]) GetId() T

func (*NameItem[T]) GetName added in v0.3.50

func (e *NameItem[T]) GetName() *string

type XmlAction added in v0.0.3

type XmlAction struct {
	XmlNameNode
	XMLName xml.Name `xml:"action"`
	Text    string   `xml:"text"`
}

type XmlController added in v0.0.3

type XmlController struct {
	XmlNameNode
	XMLName xml.Name    `xml:"controller"`
	Actions []XmlAction `xml:"action"`
}

type XmlControllers added in v0.0.3

type XmlControllers struct {
	XmlNameNode
	XMLName     xml.Name        `xml:"controllers"`
	Controllers []XmlController `xml:"controller"`
}

type XmlNameNode added in v0.0.3

type XmlNameNode struct {
	Name string `xml:"name,attr"`
}

Jump to

Keyboard shortcuts

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