summaryrefslogtreecommitdiff
path: root/cache/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'cache/cache.go')
-rw-r--r--cache/cache.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/cache/cache.go b/cache/cache.go
index 2784e23..9f25af0 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -12,18 +12,13 @@ import (
"strings"
)
+// Cache is a wrapper for its entries. I guess it could be a plain type.
type Cache struct {
Entries []Entry
}
type cacheInit struct{}
-var Init model.Initializer = &cacheInit{}
-
-func (i *cacheInit) Init() error {
- return nil
-}
-
// Merge combines two caches and filters duplicate keys
func (c *Cache) Merge(other *Cache) *Cache {
switch {
@@ -46,11 +41,13 @@ func (c *Cache) Merge(other *Cache) *Cache {
return result
}
+// Entry is a cache entry containing a path and name
type Entry struct {
Path string
Label string
}
+// String returns the string representation of this cache entry
func (e Entry) String() string {
return e.Path + " # " + e.Label
}
@@ -104,6 +101,7 @@ func (c *Cache) Marshal() []byte {
return []byte(b.String())
}
+// String returns the string representation of the Cache
func (c *Cache) String() string {
return string(c.Marshal())
}
@@ -118,6 +116,8 @@ func New(st *model.State) *Cache {
return c
}
+// MergeAndSave creates a cache from a state, combines it with
+// a potential saved context file, and writes it to disk
func MergeAndSave(in *model.State) error {
root := "/"
f := os.DirFS(root)