Documentation
¶
Overview ¶
Package lib contains some functionalities needed for expvastic. There are numeric and string searches, logging setup, etc. TODO: rename this package to "internal"
Index ¶
- func DiscardLogger() *logrus.Logger
- func FloatInSlice(niddle float64, haystack []float64) bool
- func GetLogger(level string) *logrus.Logger
- func IsGCType(key string) bool
- func IsMBType(key string) bool
- func SanitiseURL(url string) (string, error)
- func StringInMapKeys(niddle string, haystack map[string]string) bool
- func StringInSlice(niddle string, haystack []string) bool
- func Uint64InSlice(niddle uint64, haystack []uint64) bool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscardLogger ¶
DiscardLogger returns a dummy logger. This is useful for tests when you don't want to actually write to the Stdout.
func FloatInSlice ¶ added in v0.3.0
FloatInSlice returns true if niddle is in the haystack
func SanitiseURL ¶ added in v0.1.0
SanitiseURL prepends a protocol to the url if not defined, and checks if it's a valid url.
Example ¶
This example shows how to sanitise a URL.
package main import ( "fmt" "github.com/arsham/expvastic/lib" ) func main() { res, err := lib.SanitiseURL("http localhost") fmt.Printf("Error: %v\n", err) fmt.Printf("Result: <%s>\n", res) res, err = lib.SanitiseURL("127.0.0.1") fmt.Printf("Error: %v\n", err) fmt.Printf("Result: <%s>\n", res) res, _ = lib.SanitiseURL("https://localhost.localdomain") fmt.Printf("Result: <%s>\n", res) }
Output: Error: invalid url: http localhost Result: <> Error: <nil> Result: <http://127.0.0.1> Result: <https://localhost.localdomain>
func StringInMapKeys ¶ added in v0.1.0
StringInMapKeys returns true if niddle is in the haystack's keys
func StringInSlice ¶
StringInSlice returns true if niddle is in the haystack
func Uint64InSlice ¶ added in v0.3.0
Uint64InSlice returns true if niddle is in the haystack
Types ¶
This section is empty.