Documentation
¶
Index ¶
- func AddFileToZip(zipWriter *zip.Writer, filename string) error
- func ContainsString(list []string, value string) bool
- func DirectoryIsEmpty(path string) (result bool, err error)
- func FileSize(filepath string) (int64, error)
- func MakeRandomAsciiString(length int, chars []byte) string
- func ReadL10nFile(filename string, catalog *catalog.Builder) (err error)
- func StrToInt64(s string, defaultvalue int64) int64
- func StrToUInt64(s string, defaultvalue uint64) uint64
- func Unzip(srcFile string, destPath string) ([]string, error)
- func ZipFiles(destFile string, srcFiles ...string) error
- type TAverageCounter
- type TCache
- func (c TCache) CachedCount() int
- func (c TCache) CachedItems() map[string]TCachedItem
- func (c TCache) Delete(key string)
- func (c TCache) Find(findFunc func(data interface{}) bool) (data interface{}, found bool)
- func (c TCache) Flush()
- func (c TCache) Get(key string) (data interface{}, found bool)
- func (c TCache) GetDefault(key string, defaultdata interface{}) (data interface{})
- func (c TCache) MemoryConsumedRoughly() (membytes int)
- func (c TCache) OnInsertion(f func(key string, insertedItem TCachedItem))
- func (c TCache) OnNeedData(f func(key string) (data interface{}, dontcache bool))
- func (c TCache) OnRemoval(f func(key string, removedItem TCachedItem))
- func (c TCache) ReadExportedData(r io.Reader) error
- func (c TCache) ReadFromFile(fname string) error
- func (c TCache) SaveToFile(fname string) error
- func (c TCache) Set(key string, data interface{})
- func (c TCache) WriteExportedData(w io.Writer) (err error)
- type TCachedItem
- type TFileOrDirExistsResult
- type TLocationInfo
- type TLocationInfos
- type TStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadL10nFile ¶
catalog = nil -> use defaultcatalog
func Unzip ¶
Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).
Types ¶
type TAverageCounter ¶
type TAverageCounter struct { LastValue float64 Count uint64 Mean float64 // contains filtered or unexported fields }
func NewTAverageCounter ¶
func NewTAverageCounter() *TAverageCounter
func (*TAverageCounter) AddValue ¶
func (ac *TAverageCounter) AddValue(value float64)
func (*TAverageCounter) StdDeviation ¶
func (ac *TAverageCounter) StdDeviation() float64
func (*TAverageCounter) Variance ¶
func (ac *TAverageCounter) Variance() float64
type TCache ¶
type TCache struct {
// contains filtered or unexported fields
}
func NewCache ¶
Return a new cache with a given default expiration duration and cleanup interval. If the expiration duration is less than one (or NoExpiration), the items in the cache never expire (by default), and must be deleted manually. If the cleanup interval is less than one, expired items are not deleted from the cache before calling c.DeleteExpired().
func NewCacheFrom ¶
func NewCacheFrom(defaultExpiration, cleanupInterval time.Duration, items map[string]TCachedItem) *TCache
Return a new cache with a given default expiration duration and cleanup interval. If the expiration duration is less than one (or NoExpiration), the items in the cache never expire (by default), and must be deleted manually. If the cleanup interval is less than one, expired items are not deleted from the cache before calling c.DeleteExpired().
NewFrom() also accepts an items map which will serve as the underlying map for the cache. This is useful for starting from a deserialized cache (serialized using e.g. gob.Encode() on c.CachedItems()), or passing in e.g. make(map[string]TCachedItem, 500) to improve startup performance when the cache is expected to reach a certain minimum size.
Only the cache's methods synchronize access to this map, so it is not recommended to keep any references to the map around after creating a cache. If need be, the map can be accessed at a later point using c.CachedItems() (subject to the same caveat.)
Note regarding serialization: When using e.g. gob, make sure to gob.Register() the individual types stored in the cache before encoding a map retrieved with c.CachedItems(), and to register those same types before decoding a blob containing an items map.
func (TCache) CachedCount ¶
func (c TCache) CachedCount() int
Returns the number of items in the cache. This may include items that have expired, but have not yet been cleaned up.
func (TCache) CachedItems ¶
func (c TCache) CachedItems() map[string]TCachedItem
Copies all unexpired items in the cache into a new map and returns it.
func (TCache) Delete ¶
func (c TCache) Delete(key string)
Delete an item from the cache. Does nothing if the key is not in the cache.
func (TCache) Find ¶
Find an item in the cache with a find function. Returns the item or nil, and a bool indicating whether the item was found.
func (TCache) Get ¶
Get an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.
func (TCache) GetDefault ¶
func (c TCache) GetDefault(key string, defaultdata interface{}) (data interface{})
func (TCache) OnInsertion ¶
func (c TCache) OnInsertion(f func(key string, insertedItem TCachedItem))
func (TCache) OnNeedData ¶
Sets an (optional) function that is called with the key and value when an item is evicted from the cache. (Including when it is deleted manually, but not when it is overwritten.) Set to nil to disable.
func (TCache) OnRemoval ¶
func (c TCache) OnRemoval(f func(key string, removedItem TCachedItem))
Sets an (optional) function that is called with the key and value when an item is evicted from the cache. (Including when it is deleted manually, but not when it is overwritten.) Set to nil to disable.
func (TCache) ReadExportedData ¶
Add (Gob-serialized) cache items from an io.Reader, excluding any items with keys that already exist (and haven't expired) in the current cache.
func (TCache) ReadFromFile ¶
Load and add cache items from the given filename, excluding any items with keys that already exist in the current cache.
func (TCache) SaveToFile ¶
Save the cache's items to the given filename, creating the file if it doesn't exist, and overwriting it if it does.
type TFileOrDirExistsResult ¶
type TFileOrDirExistsResult byte
const ( ExistsNothing TFileOrDirExistsResult = iota ExistsFile ExistsDir ExistsOther ExistsError )
func FileOrDirExists ¶
func FileOrDirExists(filename string) TFileOrDirExistsResult
Is filename not exists or a regular file or a directory?
type TLocationInfo ¶
type TLocationInfo struct { Name string ParentName string FileName string OffsetToday int ZoneName string // = "" when this is a node ID uint64 // contains filtered or unexported fields }
func (TLocationInfo) IsNode ¶
func (li TLocationInfo) IsNode() bool
type TLocationInfos ¶
type TLocationInfos []TLocationInfo
func GetOsTimeZones ¶
func GetOsTimeZones(asTree, OnlyImportant bool) (locationInfos TLocationInfos)
func (TLocationInfos) FilterByParent ¶
func (li TLocationInfos) FilterByParent(parentName string) (result TLocationInfos)
func (TLocationInfos) FindID ¶
func (li TLocationInfos) FindID(id uint64) int
func (TLocationInfos) Len ¶
func (li TLocationInfos) Len() int
func (TLocationInfos) Less ¶
func (li TLocationInfos) Less(i, j int) bool
func (TLocationInfos) Swap ¶
func (li TLocationInfos) Swap(i, j int)
type TStats ¶
type TStats struct {
// nanosec
DurationLoadDataToCache, DurationGetDataFromCache TAverageCounter
}