Categorygithub.com/idealitsol/beacon-util
modulepackage
0.0.23
Repository: https://github.com/idealitsol/beacon-util.git
Documentation: pkg.go.dev

# README

beacon-util

Beacon Util is a small golang tool created to provide some basic commonly used snippets

# Functions

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth.
ComparePasswords ...
ConvertInterfaceToPostgresJSONB converts a field in an jsonlike interface form to postgres jsonb type.
CreateKeyValuePairs converts map to string.
ExtractHeaderToken gets or extracts token from header.
ExtractMapInterface extracts a map[string]interface based on a struct model with BXXUpdatedFields field This is used to correct gorm update to handle golang's default values like 0 for int, "" for string, false for bool, etc.
No description provided by the author
GetGormModelPrimaryKeyField returns the name of gorm primary key from the tag.
GetMD5Hash hashes string using md5.
GoTimeToGrpcTime converts golang time.Time to google protobuf timestamp.Timestamp.
GrpcError return gRPC error.
GrpcTimeToGoTime converts google protobuf timestamp.Timestamp to golang time.Time.
HashAndSalt ...
InvokeEchoHandlerFunction is used to invoke a method/function echo handler on a struct Deprecated.
InvokeFunction is a generic function used to invoke any method/function on a struct Example: * ret := util.InvokeFunction(iamc, "AuthLogin", ctx, pbxAuthLoginRequest) * res := ret[0] * err := ret[1] */.
InvokeModelConstraintFunction calls the "ConstraintError" function on a model.
IsConstraintError checks whether the given error is a unique constraint error or not.
IsValidUUID checks whether passed in uuid is valid.
JoinStrings ..
LoadConfigurationFromBranch ..
LogDatabaseQueries prints to console queries of db.
MapKeysToStringArray returns map[string]interface{} to []string.
MapStructureDecode uses mapstructure library but the reason for this is because of the stringToDate, as mapstructure.Decode(model, modelMap) does not do it well.
MarshalRequestBody ..
NewConsumer ...
RemoveDuplicatesFromSlice removes duplicates from string array.
RemoveTrailingWhiteSpaces removes all trailing whitespaces.
StartListener ..
StringContainsList checks whether a slice of string is found for a specified string.
StringFoundInArray checks whether a string is found in array of string.
TimeUUID generates a new time based UUID (version 1) using the current time as the timestamp.
TimeUUIDWith generates a new time based UUID (version 1) as described in RFC4122 with given parameters.
ToBytes parses a string formatted by ByteSize as bytes.
ToCamel converts string to Upper CamelCase.
ToCamelCaseGoLint removes all trailing whitespaces.
TokenGenerator generates token or session for mobile and desktop client.
ToLowerCamel converts string to lowerCamelCase.
ToMegabytes parses a string formatted by ByteSize as megabytes.
ToSnakeCase converts camelCase to snake_case.
ToTitleCase removes all trailing whitespaces.
TransformGoToGrpc transforms or copy over values from Golang to gRPC Example: transformerGoToGrpc(&data, &pbx.AdminUser{}).(pbx.AdminUser) pbxAdminUsers := []*pbx.AdminUser{} for _, data := range adminUsers { // pbxAdminUsers = append(pbxAdminUsers, transformAdminUserRPC(data)) data := transformerGoToGrpc(&data, &pbx.AdminUser{}).(pbx.AdminUser) pbxAdminUsers = append(pbxAdminUsers, &data) } */.
TransformGrpcToGo transforms or copy over values from gRPC to Golang adminUsers := iam.AdminUsers{} for _, data := range res.GetAdminUsers() { adminUsers = append(adminUsers, transformerGrpcToGo(data, &iam.AdminUser{}).(iam.AdminUser)) } */.
TypeOfField gets the type of interface.
UUIDFromTime generates a new time based UUID (version 1) as described in RFC 4122.
ValidateGORMFields validates gorm model fields which has either 'primary' or 'not null' properties.

# Constants

Constants.
No description provided by the author
Constant fileds.
Constants.
No description provided by the author
Constants.
Constants.
No description provided by the author
Constants.
No description provided by the author

# Variables

Constraints Constants.
ErrAuthRequired JWT Access token expires.
ErrBadRouting ...
ErrInvalidDomain produces error if Domain (User Type) is not specified.
ErrInvalidOrigin ...
ErrInvalidToken JWT Access token expires.
ErrLimitExceed ...
ErrLoginAlreadyRegisteredOnDesktop ...
ErrLoginAlreadyRegisteredOnMobile ...
ErrLoginNotAllowed prevents user from logging in based on setting value "app.auth.admin.preventlogin" or app.auth.client.preventlogin.
ErrNoDomain ...
ErrNoOrigin ...
ErrRecordAlreadyExists ...
ErrRecordNotFound ...
ErrRequestBodyLarge ...
ErrRequestBodyMalformed ...
ErrTokenInvalidated JWT Access token expires.
ErrTokenIsExpired JWT Access token expires.

# Structs

AuthorizationRequest ...
AuthorizationResponse ...
No description provided by the author
Consumer ...
GenericResponse general model.
No description provided by the author
ModelCUD defines both Created, Updated and Delete for [AT] and [BY] for gorm.
ModelCUDAt defines CreatedAt, UpdatedAt and DeleteAt for gorm.
ModelCUDBy defines CreatedBy, UpdatedBy and DeleteBy for gorm.
TransientRequest is a request for transient.
UpdateToken ..

# Type aliases

UUID ...