Skip to content

Commit

Permalink
Return concrete *os.FS from Sub() and Subvolume()
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineco committed Feb 5, 2024
1 parent e19a022 commit de5168e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions os/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewFS() *FS {

// SubVolume is like Sub, but only sets the volume name (i.e. for Windows).
// Calling SubVolume again on the returned FS results in an error.
func (fs *FS) SubVolume(volumeName string) (hackpadfs.FS, error) {
func (fs *FS) SubVolume(volumeName string) (*FS, error) {
if fs.root != "" {
return nil, &hackpadfs.PathError{Op: "subvolume", Path: volumeName, Err: errors.New("subvolume not supported on a SubFS")}
}
Expand All @@ -48,7 +48,7 @@ func (fs *FS) SubVolume(volumeName string) (hackpadfs.FS, error) {
}

// Sub implements hackpadfs.SubFS
func (fs *FS) Sub(dir string) (hackpadfs.FS, error) {
func (fs *FS) Sub(dir string) (*FS, error) {
if !hackpadfs.ValidPath(dir) {
return nil, &hackpadfs.PathError{Op: "sub", Path: dir, Err: hackpadfs.ErrInvalid}
}
Expand Down
4 changes: 2 additions & 2 deletions os/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestFSTest(t *testing.T) {
if !assert.NoError(tb, err) {
tb.FailNow()
}
fs = subvFS.(*FS)
fs = subvFS
dir = dir[len(volumeName)+1:]
} else {
dir = strings.TrimPrefix(dir, "/")
Expand All @@ -40,7 +40,7 @@ func TestFSTest(t *testing.T) {
if !assert.NoError(tb, err) {
tb.FailNow()
}
return subFS.(*FS)
return subFS
},
}
var skipFacets []fstest.Facets
Expand Down

0 comments on commit de5168e

Please sign in to comment.