util

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeString    = "String"
	TypeInt32     = "Int32"
	TypeInt64     = "Int64"
	TypeDouble    = "Double"
	TypeBool      = "Bool"
	TypeObjectId  = "ObjectID"
	TypeDate      = "Date"
	TypeTimestamp = "Timestamp"
	TypeArray     = "Array"
	TypeObject    = "Object"
	TypeRegex     = "Regex"
	TypeBinary    = "Binary"
	TypeMinKey    = "MinKey"
	TypeMaxKey    = "MaxKey"
	TypeMixed     = "Mixed"
	TypeNull      = "Null"
	TypeUndefined = "Undefined"
)
View Source
const (
	ConfigDir = "vi-mongo"
)

Variables

This section is empty.

Functions

func CleanAllWhitespaces added in v0.1.9

func CleanAllWhitespaces(s string) string

CleanAllWhitespaces removes all whitespaces from a string

func CleanJsonWhitespaces

func CleanJsonWhitespaces(s string) string

CleanJsonWhitespaces removes new lines and redundant spaces from a JSON string and also removes comma from the end of the string

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the path to the config directory

func GetMongoType

func GetMongoType(v interface{}) string

Helper function to determine MongoDB type

func GetSortedKeysWithTypes

func GetSortedKeysWithTypes(documents []primitive.M, typeColor string) []string

func HidePasswordInUri

func HidePasswordInUri(s string) string

HidePasswordInUri redacts the password in a connection string

func IsHexColor

func IsHexColor(s string) bool

IsHexColor checks if a string is a valid hex color

func IsJsonEmpty

func IsJsonEmpty(s string) bool

IsJsonEmpty checks if a JSON string is empty or only contains whitespace

func LoadConfigFile

func LoadConfigFile[T any](defaultConfig *T, configPath string) (*T, error)

LoadConfigFile loads a configuration file, merges it with defaults, and returns the result

func MergeConfigs

func MergeConfigs(loaded, defaultConfig interface{})

MergeConfigs merges the loaded config with the default config

func ParseDateToBson

func ParseDateToBson(s string) (string, error)

ParseDateToBson parses a date in a JSON string into a BSON date

func QuoteUnquotedKeys

func QuoteUnquotedKeys(s string) string

QuoteUnquotedKeys adds quotes to unquoted keys in a JSON-like string

func StringifyMongoValueByType added in v0.1.9

func StringifyMongoValueByType(v interface{}) string

StringifyMongoValueByType converts a value to a string

func TrimMultipleSpaces

func TrimMultipleSpaces(s string) string

TrimMultipleSpaces trims multiple spaces into a single space

Types

This section is empty.

Jump to

Keyboard shortcuts

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