shows implementation impact of UnimplementedFile (#1424)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
21
internal/platform/file_test.go
Normal file
21
internal/platform/file_test.go
Normal 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") }
|
||||
Reference in New Issue
Block a user