修复自定义Marshal序列化的BUG
This commit is contained in:
10
file_type.go
10
file_type.go
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user