mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-17 07:57:37 +08:00
All callers only read from the opened file (io.ReadAll + Close). Using io.ReadWriteCloser in the interface was misleading and violated the principle of interface segregation. os.Open returns a read-only file that satisfies io.ReadCloser but not the write contract implied by io.ReadWriteCloser. Narrow both the interface and the implementation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
20 lines
258 B
Go
20 lines
258 B
Go
package vfs
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
type Opener interface {
|
|
Open(name string) (io.ReadCloser, error)
|
|
}
|
|
|
|
type LocalOSOpener struct {
|
|
}
|
|
|
|
func (o LocalOSOpener) Open(name string) (io.ReadCloser, error) {
|
|
return os.Open(name)
|
|
}
|
|
|
|
var LocalOS = LocalOSOpener{}
|