77 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// 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 {
 | 
						|
	for _, fileType := range SupportFileTypeList {
 | 
						|
		if fileType.Value == ft || fileType.Value.String() == ft.String() {
 | 
						|
			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" // 未知格式
 | 
						|
)
 | 
						|
 | 
						|
type FileTypeDesc struct {
 | 
						|
	Value FileType
 | 
						|
	Desc  string
 | 
						|
}
 | 
						|
 | 
						|
var (
 | 
						|
	SupportFileTypeList = []FileTypeDesc{
 | 
						|
		{
 | 
						|
			Value: FileTypeJson,
 | 
						|
			Desc:  "json格式文件",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			Value: FileTypeIni,
 | 
						|
			Desc:  "init格式文件",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			Value: FileTypeYml,
 | 
						|
			Desc:  "yml格式文件",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			Value: FileTypeYaml,
 | 
						|
			Desc:  "yaml格式文件",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			Value: FileTypeToml,
 | 
						|
			Desc:  "toml格式文件",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			Value: FileTypeTxt,
 | 
						|
			Desc:  "txt格式文件",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			Value: FileTypeXml,
 | 
						|
			Desc:  "xml格式文件",
 | 
						|
		},
 | 
						|
	}
 | 
						|
)
 |