From a2224e380bd4463fb4f633c9f379df60847228ca Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 8 May 2016 22:38:38 +0200 Subject: [PATCH] Address style issues identified by Hound --- src/restic/snapshot.go | 6 ++++++ src/restic/testing.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/restic/snapshot.go b/src/restic/snapshot.go index 3cf8daedd..18aa9cad0 100644 --- a/src/restic/snapshot.go +++ b/src/restic/snapshot.go @@ -11,6 +11,7 @@ import ( "restic/repository" ) +// Snapshot is the state of a resource at one point in time. type Snapshot struct { Time time.Time `json:"time"` Parent *backend.ID `json:"parent,omitempty"` @@ -25,6 +26,8 @@ type Snapshot struct { id *backend.ID // plaintext ID, used during restore } +// NewSnapshot returns an initialized snapshot struct for the current user and +// time. func NewSnapshot(paths []string) (*Snapshot, error) { for i, path := range paths { if p, err := filepath.Abs(path); err != nil { @@ -50,6 +53,7 @@ func NewSnapshot(paths []string) (*Snapshot, error) { return sn, nil } +// LoadSnapshot loads the snapshot with the id and returns it. func LoadSnapshot(repo *repository.Repository, id backend.ID) (*Snapshot, error) { sn := &Snapshot{id: &id} err := repo.LoadJSONUnpacked(backend.Snapshot, id, sn) @@ -60,6 +64,7 @@ func LoadSnapshot(repo *repository.Repository, id backend.ID) (*Snapshot, error) return sn, nil } +// LoadAllSnapshots returns a list of all snapshots in the repo. func LoadAllSnapshots(repo *repository.Repository) (snapshots []*Snapshot, err error) { done := make(chan struct{}) defer close(done) @@ -80,6 +85,7 @@ func (sn Snapshot) String() string { return fmt.Sprintf("", sn.Paths, sn.Time) } +// ID retuns the snapshot's ID. func (sn Snapshot) ID() *backend.ID { return sn.id } diff --git a/src/restic/testing.go b/src/restic/testing.go index 0703772a1..fa2ab649d 100644 --- a/src/restic/testing.go +++ b/src/restic/testing.go @@ -147,7 +147,7 @@ func saveTree(t testing.TB, repo *repository.Repository, seed int64) backend.ID return id } -// TestRepositoryCreateSnapshot creates a snapshot filled with fake data. The +// TestCreateSnapshot creates a snapshot filled with fake data. The // fake data is generated deterministically from the timestamp `at`, which is // also used as the snapshot's timestamp. func TestCreateSnapshot(t testing.TB, repo *repository.Repository, at time.Time) backend.ID {