Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Detector ¶
type Detector struct { Exts []string Files []string File *regex Header *regex Priority int // 0 is lowest priority Name string }
A Detector defines a language and how it should be detected via extensions, special files, a file regex, and a header regex. A language does not need to provide every detection mechanism. In fact, most languages only need to provide an extension, which makes detection very efficient.
func LoadDetectorJson ¶
LoadDetectorJson loads a detector from a json spec.
type Detectors ¶
Detectors is a set of languages that are supported. It is a map from extension/filename to the list of detectors that are registered for those values.
func LoadDefaultDetectors ¶
func LoadDefaultDetectors() Detectors
LoadDefaultDetectors returns a set of detectors for many programming languages.
func LoadDetectors ¶
LoadDetectors loads a set of languages from a serialized Detectors byte slice.
func (Detectors) Detect ¶
Detect returns the language that was detected from the filename and file header (first line of file), or nil if no matching language was found.
func (Detectors) RegisterDetector ¶
RegisterDetector adds a new detector to the set.
func (Detectors) SetPriority ¶
SetPriority sets the priority for a certain language. A higher priority will make this language match above others when there are match conflicts.