• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 22042967129

15 Feb 2026 09:01PM UTC coverage: 61.019% (-0.03%) from 61.049%
22042967129

Pull #6111

github

andydotxyz
Move to Read/Write model
Pull Request #6111: Add a public API for caching and for cached resources

60 of 122 new or added lines in 7 files covered. (49.18%)

6 existing lines in 2 files now uncovered.

25932 of 42498 relevant lines covered (61.02%)

692.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/test/memcache.go
1
package test
2

3
import (
4
        "bytes"
5
        "errors"
6
        "io"
7
        "os"
8

9
        "fyne.io/fyne/v2"
10
        "fyne.io/fyne/v2/storage"
11
)
12

13
type memCache struct {
14
        memStore map[string][]byte
15
}
16

17
func makeCache() fyne.Cache {
35✔
18
        return &memCache{memStore: make(map[string][]byte)}
35✔
19
}
35✔
20

NEW
21
func (c *memCache) RootURI() fyne.URI {
×
NEW
22
        return storage.NewFileURI(os.TempDir()) // in case anyone wants to manually handle storage
×
NEW
23
}
×
24

NEW
25
func (c *memCache) Exists(name string) bool {
×
NEW
26
        _, ok := c.memStore[name]
×
NEW
27
        return ok
×
NEW
28
}
×
29

NEW
30
func (c *memCache) Read(name string) (io.ReadCloser, error) {
×
NEW
31
        data, ok := c.memStore[name]
×
NEW
32
        if !ok {
×
NEW
33
                return nil, errors.New("not found")
×
NEW
34
        }
×
35

NEW
36
        return io.NopCloser(bytes.NewReader(data)), nil
×
37
}
38

NEW
39
func (c *memCache) Write(name string) (io.WriteCloser, error) {
×
NEW
40
        write := &bytes.Buffer{}
×
NEW
41

×
NEW
42
        return writeCloser{write, func() {
×
NEW
43
                c.memStore[name] = write.Bytes()
×
NEW
44
        }}, nil
×
45
}
46

NEW
47
func (c *memCache) Remove(name string) error {
×
NEW
48
        delete(c.memStore, name)
×
NEW
49
        return nil
×
NEW
50
}
×
51

52
type writeCloser struct {
53
        io.Writer
54

55
        onClose func()
56
}
57

NEW
58
func (c writeCloser) Close() error {
×
NEW
59
        c.onClose()
×
NEW
60
        return nil
×
NEW
61
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc