修复自定义Marshal序列化的BUG

This commit is contained in:
2025-01-22 15:55:39 +08:00
parent c00354fe46
commit 10759d9c5e
8 changed files with 48 additions and 29 deletions

View File

@ -9,15 +9,15 @@ package consts
type FileType string
func (ft FileType) String() string {
return string(ft)
func (ft *FileType) String() string {
return string(*ft)
}
func (ft FileType) MarshalJSON() ([]byte, error) {
func (ft *FileType) MarshalJSON() ([]byte, error) {
return []byte(ft.String()), nil
}
func (ft FileType) IsValid() bool {
func (ft *FileType) IsValid() bool {
supportFileTypeList := []FileType{
FileTypeJson,
FileTypeIni,
@ -28,7 +28,7 @@ func (ft FileType) IsValid() bool {
FileTypeTxt,
}
for _, fileType := range supportFileTypeList {
if fileType == ft {
if fileType == *ft {
return true
}
}