File: types.go

package info (click to toggle)
golang-gopkg-h2non-filetype.v1 1.1.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 4
file content (23 lines) | stat: -rw-r--r-- 389 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package types

import "sync"

// Types Support concurrent map writes
var Types sync.Map

// Add registers a new type in the package
func Add(t Type) Type {
	Types.Store(t.Extension, t)
	return t
}

// Get retrieves a Type by extension
func Get(ext string) Type {
	if tmp, ok := Types.Load(ext); ok {
		kind := tmp.(Type)
		if kind.Extension != "" {
			return kind
		}
	}
	return Unknown
}