From 1f79a19293749025c133b5ca6365cbfe9d6363e3 Mon Sep 17 00:00:00 2001 From: Matthieu Rakotojaona Date: Sat, 18 Jul 2015 21:52:10 +0200 Subject: [PATCH] Comment the go trick about static verification of a struct implementing an interface --- cmd/restic/cmd_mount.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go index 1f3b54ad6..96241be2d 100644 --- a/cmd/restic/cmd_mount.go +++ b/cmd/restic/cmd_mount.go @@ -94,6 +94,9 @@ func (cmd CmdMount) Execute(args []string) error { return c.MountError } +// These lines statically ensure that a *snapshots implement the given +// interfaces; a misplaced refactoring of the implementation that breaks +// the interface will be catched by the compiler var _ = fs.HandleReadDirAller(&snapshots{}) var _ = fs.NodeStringLookuper(&snapshots{}) @@ -155,6 +158,7 @@ func (sn *snapshots) Lookup(ctx context.Context, name string) (fs.Node, error) { return nil, fuse.ENOENT } +// Statically ensure that *dir implement those interface var _ = fs.HandleReadDirAller(&dir{}) var _ = fs.NodeStringLookuper(&dir{}) @@ -215,6 +219,7 @@ func (d *dir) Lookup(ctx context.Context, name string) (fs.Node, error) { return nil, fuse.ENOENT } +// Statically ensure that *file implements the given interface var _ = fs.HandleReader(&file{}) type file struct {