2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 23:06:32 +00:00

Comment the go trick about static verification of a struct implementing an interface

This commit is contained in:
Matthieu Rakotojaona 2015-07-18 21:52:10 +02:00
parent a8cd74ba7e
commit 1f79a19293

View File

@ -94,6 +94,9 @@ func (cmd CmdMount) Execute(args []string) error {
return c.MountError 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.HandleReadDirAller(&snapshots{})
var _ = fs.NodeStringLookuper(&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 return nil, fuse.ENOENT
} }
// Statically ensure that *dir implement those interface
var _ = fs.HandleReadDirAller(&dir{}) var _ = fs.HandleReadDirAller(&dir{})
var _ = fs.NodeStringLookuper(&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 return nil, fuse.ENOENT
} }
// Statically ensure that *file implements the given interface
var _ = fs.HandleReader(&file{}) var _ = fs.HandleReader(&file{})
type file struct { type file struct {