Skip to content

Commit

Permalink
fix: go-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Clov614 committed Jul 30, 2024
1 parent 1eb9fa1 commit d4c57f7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rikkabot/utils/imgutil/imgutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package imgutil
import (
"bytes"
"crypto/tls"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -95,6 +96,10 @@ var SignatureMap = map[FileType][][]byte{
},
}

var (
ErrUnknowFileType = errors.New("unknown file type")
)

// DetectFileType 检测文件的字节前缀以确定其类型
func DetectFileType(data []byte) (FileType, error) {
for fileType, signatures := range SignatureMap {
Expand All @@ -104,7 +109,7 @@ func DetectFileType(data []byte) (FileType, error) {
}
}
}
return "", fmt.Errorf("unknown file type")
return "", fmt.Errorf("detectFileType: %w", ErrUnknowFileType)
}

// GetMimeTypeByFileType 根据 FileType 返回 MIME 类型
Expand Down

0 comments on commit d4c57f7

Please sign in to comment.