From 20017ca5e6bc433bab2ba5f450b93499627fbfed Mon Sep 17 00:00:00 2001 From: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Date: Tue, 2 May 2023 07:31:17 +0800 Subject: [PATCH] shows implementation impact of UnimplementedFile (#1424) Signed-off-by: Adrian Cole --- internal/platform/file_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 internal/platform/file_test.go diff --git a/internal/platform/file_test.go b/internal/platform/file_test.go new file mode 100644 index 00000000..5a8c100c --- /dev/null +++ b/internal/platform/file_test.go @@ -0,0 +1,21 @@ +package platform + +import ( + "io/fs" + "syscall" +) + +var _ File = NoopFile{} + +// NoopFile shows the minimal methods a type embedding UnimplementedFile must +// implement. +type NoopFile struct { + UnimplementedFile +} + +// The current design requires the user to consciously implement Close. +// However, we could change UnimplementedFile to return zero. +func (n NoopFile) Close() (errno syscall.Errno) { return } + +// Once File.File is removed, it will be possible to implement NoopFile. +func (n NoopFile) File() fs.File { panic("noop") }