Skip to content

Commit 5b6fef5

Browse files
committed
refactor: refactor logging and error handling using log/slog package
- Replace `log` package with `log/slog` - Change error handling to use `slog.Error` and return `nil` on failure Signed-off-by: appleboy <[email protected]>
1 parent 3cbc5ca commit 5b6fef5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

embed_folder.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package static
33
import (
44
"embed"
55
"io/fs"
6-
"log"
6+
"log/slog"
77
"net/http"
88
)
99

@@ -19,7 +19,11 @@ func (e embedFileSystem) Exists(prefix string, path string) bool {
1919
func EmbedFolder(fsEmbed embed.FS, targetPath string) ServeFileSystem {
2020
fsys, err := fs.Sub(fsEmbed, targetPath)
2121
if err != nil {
22-
log.Fatalf("static.EmbedFolder - Invalid targetPath value - %s", err)
22+
slog.Error("Failed to embed folder",
23+
"targetPath", targetPath,
24+
"error", err,
25+
)
26+
return nil
2327
}
2428
return embedFileSystem{
2529
FileSystem: http.FS(fsys),

0 commit comments

Comments
 (0)