Documentation ¶
Index ¶
- func AskPassword(name string) (secret string)
- func Decrypt(key []byte, text string) (decrypted string, err error)
- func DecryptStr(key string, text string) (decrypted string, err error)
- func DumpJSON(o interface{})
- func Encrypt(key []byte, text string) (encrypted string, err error)
- func EncryptStr(key string, text string) (encrypted string, err error)
- func ErrString(err error) string
- func ExistsAsDir(path string) (yes bool)
- func ExistsAsFile(path string) (yes bool)
- func FirstValid(errs ...error) (err error)
- func GetAsJSON(o interface{}) (jstr string, err error)
- func GetConfig(key string, value interface{}) (err error)
- func GetExecDir() (dirPath string)
- func GetFirstValidStr(strs ...string) (str string)
- func GetStringConfig(key string) (value string)
- func HasConfig(key string) (yes bool)
- func Hash(in string) (out string)
- func LoadConfig(appName string)
- func PrintConfig()
- type ArgGetter
- func (retriever *ArgGetter) GetBool(key string) (val bool)
- func (retriever *ArgGetter) GetInt(key string) (val int)
- func (retriever *ArgGetter) GetOptionalInt(key string) (val int)
- func (retriever *ArgGetter) GetOptionalString(key string) (val string)
- func (retriever *ArgGetter) GetRequiredBool(key string) (val bool)
- func (retriever *ArgGetter) GetRequiredInt(key string) (val int)
- func (retriever *ArgGetter) GetRequiredSecret(key string) (val string)
- func (retriever *ArgGetter) GetRequiredString(key string) (val string)
- func (retriever *ArgGetter) GetString(key string) (val string)
- type CountList
- type DateRange
- type Filter
- type FilterSpec
- type FilterSpecList
- type FilterType
- type FilterVal
- type MatchStrategy
- type Matcher
- type Pair
- type Param
- type ParamType
- type PropMatcher
- type Range
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskPassword ¶
AskPassword - asks password, prints the given name before asking
func DecryptStr ¶
DecryptStr - AES decrypts input text with given key string
func DumpJSON ¶
func DumpJSON(o interface{})
DumpJSON - dumps JSON representation of given data to stdout
func EncryptStr ¶
EncryptStr - AES encrypts input text with given key string
func ExistsAsDir ¶
ExistsAsDir - checks if a directory exists at given path. If a error occurs while stating whatever exists at given location, false is returned
func ExistsAsFile ¶
ExistsAsFile - checks if a regular file exists at given path. If a error occurs while stating whatever exists at given location, false is returned
func FirstValid ¶
FirstValid - returns the first error that is not nil
func GetConfig ¶
GetConfig - retrieves config value for the given key and populates the value argument given. If the key does not exist in the config map or if its not possible to populate value arg from retrieved value and error is returned
func GetExecDir ¶
func GetExecDir() (dirPath string)
GetExecDir - gives absolute path of the directory in which the executable for the current application is present
func GetFirstValidStr ¶
GetFirstValidStr - gets first string that is not empty
func GetStringConfig ¶
GetStringConfig - gets a value associated with config key
func LoadConfig ¶
func LoadConfig(appName string)
LoadConfig - loads configuration for app with given appName. Searches for configuration file in standard locations and loads based all of them. If same config values is present in different files, value for the file that is loaded last is kept
Types ¶
type ArgGetter ¶
type ArgGetter struct { Err error // contains filtered or unexported fields }
ArgGetter - this struct and its method are helpers to combine getting args from commandline arguments or from reading from console. Also handles errors when required arguments are not provided
func NewArgGetter ¶
NewArgGetter - creates a new argument retriever with given context
func (*ArgGetter) GetBool ¶
GetBool - gives a Boolean argument either from commandline or from blocking user input, this method doesnt complain even if the arg-value is empty
func (*ArgGetter) GetInt ¶
GetInt - gives a Integer argument either from commandline or from blocking user input, this method doesnt complain even if the arg-value is empty
func (*ArgGetter) GetOptionalInt ¶
GetOptionalInt - retrieves int from commandline, if not provided it wont ask again from stdin
func (*ArgGetter) GetOptionalString ¶
GetOptionalString - retrieves string from commandline, if not provided it wont ask again from stdin
func (*ArgGetter) GetRequiredBool ¶
GetRequiredBool - gives a Boolean argument either from commandline or from blocking user input, this method sets the error if required arg-val is empty
func (*ArgGetter) GetRequiredInt ¶
GetRequiredInt - gives a Integer argument either from commandline or from blocking user input, this method sets the error if required arg-val is empty
func (*ArgGetter) GetRequiredSecret ¶
GetRequiredSecret - gives a string argument either from commandline or from blocking user input, this method sets the error if required arg-val is empty
func (*ArgGetter) GetRequiredString ¶
GetRequiredString - gives a string argument either from commandline or from blocking user input, this method sets the error if required arg-val is empty
type CountList ¶
type CountList struct { TotalCount int `json:"total" bson:"total"` Data interface{} `json:"data" bson:"data"` }
CountList - paginated list returned from mongoDB along with total number of items in the list counted without pagination
type DateRange ¶
type DateRange struct { // Name string `json:"name" bson:"name"` From time.Time `json:"from" bson:"from" sql:"from"` To time.Time `json:"to" bson:"to" sql:"to"` }
DateRange - represents date ranges
type Filter ¶
type Filter struct { Props map[string]Matcher `json:"props" bson:"props"` Bools map[string]interface{} `json:"bools" bson:"bools"` Dates map[string]DateRange `json:"dates" bson:"dates"` Lists map[string]Matcher `json:"lists" bson:"lists"` Searches map[string][]interface{} `json:"searches" bson:"searches"` }
Filter - generic filter used to filter data in any mongodb collection
type FilterSpec ¶
type FilterSpec struct { Field string `json:"field" bson:"field"` Name string `json:"name" bson:"name"` Type FilterType `json:"type" bson:"type"` }
FilterSpec - filter specification
type FilterSpecList ¶
type FilterSpecList []*FilterSpec
FilterSpecList - alias for array of filter specs
type FilterType ¶
type FilterType string
FilterType - Type of filter item
const Array FilterType = "array'"
Array - filter for an array
const Boolean FilterType = "boolean"
Boolean - filter for boolean field
const Constant FilterType = "constant"
Constant - constant filter value
const Date FilterType = "dateRange"
Date - filter for data range
const Prop FilterType = "prop"
Prop - filter for a value
const Search FilterType = "search"
Search - filter for search text field
const Static FilterType = "static"
Static - constant filter value
type FilterVal ¶
type FilterVal struct { Name string `json:"name" bson:"_id"` Count int `json:"count" bson:"count"` }
FilterVal - values for filter along with the count
type MatchStrategy ¶
type MatchStrategy string
MatchStrategy - strategy to match multiple fields passed as part of the filters
const MatchAll MatchStrategy = "all"
MatchAll - match all provided values while executing filter
const MatchNone MatchStrategy = "none"
MatchNone - match values that are not part of the provided list while executing filter
const MatchOne MatchStrategy = "one"
MatchOne - match atleast one of the provided values while executing filter
type Matcher ¶
type Matcher struct { Strategy MatchStrategy `json:"strategy" bson:"strategy"` Fields []interface{} `json:"fields" bson:"fields"` }
Matcher - matches the given fields. If multiple fileds are given the; the joining condition is decided by the MatchStrategy given
type Pair ¶
type Pair struct { Key string `json:"key" bson:"key" sql:"key"` Value string `json:"value" bson:"value" sql:"value"` }
Pair - association of key and value
type Param ¶
type Param struct { Name string `json:"name" bson:"name" sql:"name"` Type ParamType `json:"type" bson:"type" sql:"type"` Desc string `json:"desc" bson:"desc" sql:"desc"` Range Range `json:"range" bson:"range" sql:"range"` Choices []Pair `json:"choices" bson:"choices" sql:"choices"` Default interface{} `json:"def" bson:"def" sql:"def"` }
Param - represents generic parameter