// Package consts ... // // Description : consts ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2023-08-11 10:59 package consts type FileType string func (ft *FileType) String() string { return string(*ft) } func (ft *FileType) MarshalJSON() ([]byte, error) { return []byte(ft.String()), nil } func (ft *FileType) IsValid() bool { supportFileTypeList := []FileType{ FileTypeJson, FileTypeIni, FileTypeYml, FileTypeYaml, FileTypeToml, FileTypeXml, FileTypeTxt, } for _, fileType := range supportFileTypeList { if fileType == *ft { return true } } return false } const ( FileTypeJson FileType = "json" // json格式文件 FileTypeIni FileType = "ini" // ini格式文件 FileTypeYml FileType = "yml" // yml 格式文件 FileTypeYaml FileType = "yaml" // yaml格式文件 FileTypeToml FileType = "toml" // toml格式文件 FileTypeXml FileType = "xml" // xml格式文件 FileTypeTxt FileType = "txt" // txt格式文件 FileTypeUnknown FileType = "unknown" // 未知格式 )