From a0c06e5615e8928e224ccbac1d9376329a38ca30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Wed, 20 Apr 2022 22:51:06 +0200 Subject: [PATCH] Add list to store --- store/memory.go | 11 +++++++++++ store/store.go | 1 + 2 files changed, 12 insertions(+) diff --git a/store/memory.go b/store/memory.go index d4e2351..089fd12 100644 --- a/store/memory.go +++ b/store/memory.go @@ -8,6 +8,8 @@ import ( "github.com/google/uuid" ) +var _ Store = &MemoryStore{} + type MemoryStore struct { data map[string][]byte } @@ -44,3 +46,12 @@ func (s *MemoryStore) Get(id string) (io.ReadCloser, error) { return r, nil } + +func (s *MemoryStore) List() ([]string, error) { + var ids []string + for id := range s.data { + ids = append(ids, id) + } + + return ids, nil +} diff --git a/store/store.go b/store/store.go index c4482d6..b086c59 100644 --- a/store/store.go +++ b/store/store.go @@ -11,4 +11,5 @@ type Store interface { Add(r io.Reader) (string, error) Delete(id string) error Get(id string) (io.ReadCloser, error) + List() ([]string, error) }