Skip to content

Commit bcba4a1

Browse files
committed
use os root
1 parent e7cc140 commit bcba4a1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,3 @@ tls/
3333
# builds
3434
bin/
3535
dist/
36-
goserve
37-
goserve.exe

pkg/cmd/goserve/goserve.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,19 @@ func run(cmd *cobra.Command, args []string) error {
105105
var fileSystem fs.FS
106106

107107
if pathInfo.IsDir() {
108-
fileSystem = os.DirFS(path)
108+
root, err := os.OpenRoot(path)
109+
if err != nil {
110+
return err
111+
}
112+
113+
fileSystem = root.FS()
109114
} else {
110-
fileSystem = os.DirFS(filepath.Dir(path))
115+
root, err := os.OpenRoot(filepath.Dir(path))
116+
if err != nil {
117+
return err
118+
}
119+
120+
fileSystem = root.FS()
111121

112122
fileSystem, err = fs.Sub(fileSystem, filepath.Base(path))
113123
if err != nil {

0 commit comments

Comments
 (0)