| 1 | package types |
| 2 | |
| 3 | import "sync" |
| 4 | |
| 5 | // Types Support concurrent map writes |
| 6 | var Types sync.Map |
| 7 | |
| 8 | // Add registers a new type in the package |
| 9 | func Add(t Type) Type { |
| 10 | Types.Store(t.Extension, t) |
| 11 | return t |
| 12 | } |
| 13 | |
| 14 | // Get retrieves a Type by extension |
| 15 | func Get(ext string) Type { |
| 16 | if tmp, ok := Types.Load(ext); ok { |
| 17 | kind := tmp.(Type) |
| 18 | if kind.Extension != "" { |
| 19 | return kind |
| 20 | } |
| 21 | } |
| 22 | return Unknown |
| 23 | } |