From eb1669a061a0484027fde9b2ce6902b36935a43f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 26 Jan 2016 21:56:13 +0100 Subject: [PATCH] Add a lot of comments --- backend/mock_backend.go | 9 +++++++++ backend/paths.go | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/mock_backend.go b/backend/mock_backend.go index e685ba556..921af4d6c 100644 --- a/backend/mock_backend.go +++ b/backend/mock_backend.go @@ -16,6 +16,7 @@ type MockBackend struct { LocationFn func() string } +// Close the backend. func (m *MockBackend) Close() error { if m.CloseFn == nil { return nil @@ -24,6 +25,7 @@ func (m *MockBackend) Close() error { return m.CloseFn() } +// Location returns a location string. func (m *MockBackend) Location() string { if m.LocationFn == nil { return "" @@ -32,6 +34,7 @@ func (m *MockBackend) Location() string { return m.LocationFn() } +// Load loads data from the backend. func (m *MockBackend) Load(h Handle, p []byte, off int64) (int, error) { if m.LoadFn == nil { return 0, errors.New("not implemented") @@ -40,6 +43,7 @@ func (m *MockBackend) Load(h Handle, p []byte, off int64) (int, error) { return m.LoadFn(h, p, off) } +// Save data in the backend. func (m *MockBackend) Save(h Handle, p []byte) error { if m.SaveFn == nil { return errors.New("not implemented") @@ -48,6 +52,7 @@ func (m *MockBackend) Save(h Handle, p []byte) error { return m.SaveFn(h, p) } +// Stat an object in the backend. func (m *MockBackend) Stat(h Handle) (BlobInfo, error) { if m.StatFn == nil { return BlobInfo{}, errors.New("not implemented") @@ -56,6 +61,7 @@ func (m *MockBackend) Stat(h Handle) (BlobInfo, error) { return m.StatFn(h) } +// List items of type t. func (m *MockBackend) List(t Type, done <-chan struct{}) <-chan string { if m.ListFn == nil { ch := make(chan string) @@ -66,6 +72,7 @@ func (m *MockBackend) List(t Type, done <-chan struct{}) <-chan string { return m.ListFn(t, done) } +// Remove data from the backend. func (m *MockBackend) Remove(t Type, name string) error { if m.RemoveFn == nil { return errors.New("not implemented") @@ -74,6 +81,7 @@ func (m *MockBackend) Remove(t Type, name string) error { return m.RemoveFn(t, name) } +// Test for the existence of a specific item. func (m *MockBackend) Test(t Type, name string) (bool, error) { if m.TestFn == nil { return false, errors.New("not implemented") @@ -82,6 +90,7 @@ func (m *MockBackend) Test(t Type, name string) (bool, error) { return m.TestFn(t, name) } +// Delete all data. func (m *MockBackend) Delete() error { if m.DeleteFn == nil { return errors.New("not implemented") diff --git a/backend/paths.go b/backend/paths.go index 8e29e6950..940e9fcb9 100644 --- a/backend/paths.go +++ b/backend/paths.go @@ -2,7 +2,7 @@ package backend import "os" -// Default paths for file-based backends (e.g. local) +// Paths contains the default paths for file-based backends (e.g. local). var Paths = struct { Data string Snapshots string @@ -21,5 +21,6 @@ var Paths = struct { "config", } -// Default modes for file-based backends +// Modes holds the default modes for directories and files for file-based +// backends. var Modes = struct{ Dir, File os.FileMode }{0700, 0600}