andrey1s
2 years ago
11 changed files with 25562 additions and 10082 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,19 +1,58 @@ |
|||
// 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 $key, $value := .Extensions }} |
|||
{{ name $.ExtPrefix $key }} = "{{ $key }}" |
|||
{{- range $value := .Extensions }} |
|||
{{ name $.ExtPrefix $value.Name }} Ext = {{ $value.ID }} |
|||
{{- end}} |
|||
) |
|||
|
|||
func Mime(name string) []string { |
|||
func ExtFromString(name string) Ext { |
|||
switch name { |
|||
{{- range $key, $value := .Extensions }} |
|||
case {{ name $.ExtPrefix $key }}: |
|||
return {{ value $value }} |
|||
{{- range $value := .Extensions }} |
|||
case "{{- $value.Name -}}": |
|||
return {{ name $.ExtPrefix $value.Name }} |
|||
{{- end}} |
|||
} |
|||
|
|||
return nil |
|||
return 0 |
|||
} |
|||
|
|||
|
@ -1,19 +1,57 @@ |
|||
// Code generated by gitoa.ru/go-4devs/mime and sourse {{.Source}} |
|||
package {{.MimePackage}} |
|||
|
|||
import "fmt" |
|||
|
|||
type Mime int |
|||
|
|||
type MimeTypes []Mime |
|||
|
|||
func (v Mime) Is(types ...Mime) bool { |
|||
for _, mime := range types { |
|||
if mime == v { |
|||
return true |
|||
} |
|||
} |
|||
|
|||
return false |
|||
} |
|||
|
|||
func (v Mime) String() string { |
|||
switch v { |
|||
{{- range $value := .Mimes }} |
|||
case {{ name $.MimePrefix $value.Name }}: |
|||
return "{{- $value.Name -}}" |
|||
{{- end}} |
|||
} |
|||
|
|||
return fmt.Sprintf("Mime(%d)",v) |
|||
} |
|||
|
|||
func (v Mime) ExtTypes() ExtTypes{ |
|||
switch v { |
|||
{{- range $value := .Mimes }} |
|||
case {{ name $.MimePrefix $value.Name }}: |
|||
return []Ext{ {{- value $.ExtPrefix $value.Value -}} } |
|||
{{- end}} |
|||
} |
|||
|
|||
return nil |
|||
} |
|||
|
|||
const ( |
|||
{{- range $key, $value := .Mimes }} |
|||
{{ name $.MimePrefix $key }} = "{{ $key }}" |
|||
{{- range $value := .Mimes }} |
|||
{{ name $.MimePrefix $value.Name }} Mime = {{ $value.ID }} |
|||
{{- end}} |
|||
) |
|||
|
|||
func Extension(name string) []string { |
|||
func MimeFromString(name string) Mime { |
|||
switch name { |
|||
{{- range $key, $value := .Mimes }} |
|||
case {{ name $.MimePrefix $key }}: |
|||
return {{ value $value }} |
|||
{{- range $value := .Mimes }} |
|||
case "{{- $value.Name -}}": |
|||
return {{ name $.MimePrefix $value.Name }} |
|||
{{- end}} |
|||
} |
|||
|
|||
return nil |
|||
return 0 |
|||
} |
|||
|
Loading…
Reference in new issue