Skip to content

Commit

Permalink
refactor: refactor logging and error handling using log/slog package
Browse files Browse the repository at this point in the history
- Replace `log` package with `log/slog`
- Change error handling to use `slog.Error` and return `nil` on failure

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Dec 29, 2024
1 parent 3cbc5ca commit 5b6fef5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions embed_folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package static
import (
"embed"
"io/fs"
"log"
"log/slog"
"net/http"
)

Expand All @@ -19,7 +19,11 @@ func (e embedFileSystem) Exists(prefix string, path string) bool {
func EmbedFolder(fsEmbed embed.FS, targetPath string) ServeFileSystem {
fsys, err := fs.Sub(fsEmbed, targetPath)
if err != nil {
log.Fatalf("static.EmbedFolder - Invalid targetPath value - %s", err)
slog.Error("Failed to embed folder",
"targetPath", targetPath,
"error", err,
)
return nil
}
return embedFileSystem{
FileSystem: http.FS(fsys),
Expand Down

0 comments on commit 5b6fef5

Please sign in to comment.