fix: check error type on file not found (#2383)

This commit is contained in:
BoYanZh 2022-11-18 01:30:37 +08:00 committed by GitHub
parent 8beeba7c0c
commit a02d9c8463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package static
import (
"errors"
"fmt"
"io/fs"
"net/http"
@ -18,7 +19,7 @@ import (
func InitIndex() {
index, err := public.Public.ReadFile("dist/index.html")
if err != nil {
if err == fs.ErrNotExist {
if errors.Is(err, fs.ErrNotExist) {
utils.Log.Fatalf("index.html not exist, you may forget to put dist of frontend to public/dist")
}
utils.Log.Fatalf("failed to read index.html: %v", err)