You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
998 B
58 lines
998 B
// Code generated by gitoa.ru/go-4devs/mime and sourse {{.Source}}
|
|
package {{.ExtPackage}}
|
|
|
|
import "fmt"
|
|
|
|
type Ext int
|
|
|
|
type ExtTypes []Ext
|
|
|
|
func (v Ext) Is(types ...Ext) bool {
|
|
for _, ext := range types {
|
|
if ext == v {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (v Ext) String() string {
|
|
switch v {
|
|
{{- range $value := .Extensions }}
|
|
case {{ name $.ExtPrefix $value.Name }}:
|
|
return "{{- $value.Name -}}"
|
|
{{- end}}
|
|
}
|
|
|
|
return fmt.Sprintf("Ext(%d)",v)
|
|
}
|
|
|
|
func (v Ext) MimeTypes() MimeTypes{
|
|
switch v {
|
|
{{- range $value := .Extensions }}
|
|
case {{ name $.ExtPrefix $value.Name }}:
|
|
return MimeTypes{ {{- value $.MimePrefix $value.Value -}} }
|
|
{{- end}}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
const (
|
|
{{- range $value := .Extensions }}
|
|
{{ name $.ExtPrefix $value.Name }} Ext = {{ $value.ID }}
|
|
{{- end}}
|
|
)
|
|
|
|
func ExtFromString(name string) Ext {
|
|
switch name {
|
|
{{- range $value := .Extensions }}
|
|
case "{{- $value.Name -}}":
|
|
return {{ name $.ExtPrefix $value.Name }}
|
|
{{- end}}
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
|