Documentation ¶
Index ¶
- Constants
- func Copy(i any) any
- func ExpandTemplate(t string, lookup VariableLookup) (string, error)
- func FmtTimestamp(t time.Time) string
- func IsNil(a any) bool
- func IsNillable(a any) bool
- func IsPointer(a any) bool
- func IsPointerType(a any) bool
- func IsSerializable(i any) bool
- func MapSubset(keys []string, m map[string]string) map[string]string
- func SimpleHash(s string) uint32
- func TrimDoubleSpace(s string) string
- type DictionaryValue
- type InvertedDictionary
- type List
- type SyncList
- type VariableLookup
Examples ¶
Constants ¶
View Source
const ( TemplateBeginDelimiter = "{" TemplateEndDelimiter = "}" )
View Source
const (
DictionaryValueNotFound = DictionaryValue(-1)
)
View Source
const (
EnvTemplateVar = "{env}"
)
Variables ¶
This section is empty.
Functions ¶
func ExpandTemplate ¶
func ExpandTemplate(t string, lookup VariableLookup) (string, error)
func FmtTimestamp ¶
Example ¶
s := FmtTimestamp(time.Now()) fmt.Printf("Timestamp : %v\n", s)
Output:
func IsNil ¶
IsNil - determine if the interface{} holds is nil
Example ¶
var i any fmt.Printf("Nil any : %v\n", IsNil(i)) fmt.Printf("Wrapped nil Nil pointer : %v\n", IsNil(i))
Output: Nil any : true Wrapped nil Nil pointer : true
func IsNillable ¶
func IsPointer ¶
Example ¶
var i any var s string var data = testStruct{} var count int var bytes []byte fmt.Printf("any : %v\n", IsPointer(i)) fmt.Printf("int : %v\n", IsPointer(count)) fmt.Printf("int * : %v\n", IsPointer(&count)) fmt.Printf("string : %v\n", IsPointer(s)) fmt.Printf("string * : %v\n", IsPointer(&s)) fmt.Printf("struct : %v\n", IsPointer(data)) fmt.Printf("struct * : %v\n", IsPointer(&data)) fmt.Printf("[]byte : %v\n", IsPointer(bytes)) //fmt.Printf("Struct * : %v\n", IsPointer(&data))
Output: any : false int : false int * : true string : false string * : true struct : false struct * : true []byte : false
func IsPointerType ¶
func IsSerializable ¶
IsSerializable - determine if any can be serialized
func SimpleHash ¶
func TrimDoubleSpace ¶
Example ¶
s := "' this is an example of do uble spaces '" fmt.Printf("String : %v\n", TrimDoubleSpace(s))
Output: String : ' this is an example of do uble spaces '
Types ¶
type DictionaryValue ¶
type DictionaryValue int32
type InvertedDictionary ¶
type InvertedDictionary struct {
// contains filtered or unexported fields
}
InvertedDictionary - used for inverted content, where key = string, value = id. // The im is used for normal lookups key = id, value = string
Example ¶
dict := CreateInvertedDictionary() fmt.Printf("Empty : %v\n", dict.IsEmpty()) val := dict.Lookup("") fmt.Printf("Lookup [''] : %v\n\n", val) val = dict.Add("") fmt.Printf("Add [''] : %v\n", val) fmt.Printf("Empty : %v\n", dict.IsEmpty()) val = dict.Lookup("") fmt.Printf("Lookup [''] : %v\n\n", val) val = dict.Add("new-key") fmt.Printf("Add [new-key] : %v\n", val) val = dict.Lookup("new-key") fmt.Printf("Lookup [new-key] : %v\n\n", val) val = dict.Add("new-key2") fmt.Printf("Add [new-key2] : %v\n", val) val = dict.Lookup("new-key2") fmt.Printf("Lookup [new-key2] : %v\n\n", val) var found = false var val2 string val2, found = dict.InverseLookup(1) fmt.Printf("LookupKey [1] : %v %v\n\n", val2, found) val2, found = dict.InverseLookup(2) fmt.Printf("LookupKey [2] : %v %v\n\n", val2, found) val2, found = dict.InverseLookup(3) fmt.Printf("LookupKey [3] : %v %v\n\n", val2, found)
Output: Empty : true Lookup [''] : -1 Add [''] : 0 Empty : false Lookup [''] : 0 Add [new-key] : 1 Lookup [new-key] : 1 Add [new-key2] : 2 Lookup [new-key2] : 2 LookupKey [1] : new-key true LookupKey [2] : new-key2 true LookupKey [3] : false
func CreateInvertedDictionary ¶
func CreateInvertedDictionary() *InvertedDictionary
func (*InvertedDictionary) Add ¶
func (d *InvertedDictionary) Add(key string) DictionaryValue
func (*InvertedDictionary) InverseLookup ¶
func (d *InvertedDictionary) InverseLookup(value DictionaryValue) (string, bool)
func (*InvertedDictionary) IsEmpty ¶
func (d *InvertedDictionary) IsEmpty() bool
func (*InvertedDictionary) Lookup ¶
func (d *InvertedDictionary) Lookup(key string) DictionaryValue
type List ¶
type List map[any]struct{}
Example ¶
package main import ( "fmt" ) func main() { uri := "www.google.com/search" links := make(List) links.Add(uri) fmt.Printf("Test - {Added} : %v\n", links) fmt.Printf("Test - {Is Empty} : %v\n", links.IsEmpty()) fmt.Printf("Test - {Item} : %v\n", links[uri]) fmt.Printf("Test - {Contains} : %v\n", links.Contains(uri)) fmt.Printf("Test - {Contains invalid} : %v\n", links.Contains("invalid")) links.Remove(uri) fmt.Printf("Test - {Remove item} : %v\n", links) fmt.Printf("Test - {Is Empty} : %v\n", links.IsEmpty()) } func _ExampleSyncList() { uri := "www.google.com/search" links := new(SyncList) links.Add(uri) fmt.Printf("Test - {Added} : %v\n", links) fmt.Printf("Test - {Contains} : %v\n", links.Contains(uri)) fmt.Printf("Test - {Contains invalid} : %v\n", links.Contains("invalid")) links.Remove(uri) fmt.Printf("Test - {Remove item} : %v\n", links)
Output: Test - {Added} : map[www.google.com/search:{}] Test - {Is Empty} : false Test - {Item} : {} Test - {Contains} : true Test - {Contains invalid} : false Test - {Remove item} : map[] Test - {Is Empty} : true
type VariableLookup ¶
VariableLookup - type used in template.go
Source Files ¶
Click to show internal directories.
Click to hide internal directories.