mirror of
https://github.com/golang/go
synced 2024-11-17 13:54:46 -07:00
embed: guarantee the returned file of FS.Open implements io.Seeker
Fixes golang/go#45745 Change-Id: Ib49a9605a38074f544a5d28116862e191cea8c0f Reviewed-on: https://go-review.googlesource.com/c/go/+/313352 Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
c69f5c0d76
commit
90c5660616
@ -291,6 +291,8 @@ func (f FS) readDir(dir string) []file {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open opens the named file for reading and returns it as an fs.File.
|
// Open opens the named file for reading and returns it as an fs.File.
|
||||||
|
//
|
||||||
|
// The returned file implements io.Seeker when the file is not a directory.
|
||||||
func (f FS) Open(name string) (fs.File, error) {
|
func (f FS) Open(name string) (fs.File, error) {
|
||||||
file := f.lookup(name)
|
file := f.lookup(name)
|
||||||
if file == nil {
|
if file == nil {
|
||||||
@ -338,6 +340,10 @@ type openFile struct {
|
|||||||
offset int64 // current read offset
|
offset int64 // current read offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ io.Seeker = (*openFile)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (f *openFile) Close() error { return nil }
|
func (f *openFile) Close() error { return nil }
|
||||||
func (f *openFile) Stat() (fs.FileInfo, error) { return f.f, nil }
|
func (f *openFile) Stat() (fs.FileInfo, error) { return f.f, nil }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user