shows implementation impact of UnimplementedFile (#1424)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-05-02 07:31:17 +08:00
committed by GitHub
parent 18c793f8e6
commit 20017ca5e6

View File

@@ -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") }