mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
fixed GetLanguageType to return Unknown when language is not found in languagesType map
This commit is contained in:
parent
664afe48d4
commit
cbf44205e0
@ -17,7 +17,11 @@ const (
|
||||
|
||||
// GetLanguageType returns the given language's type.
|
||||
func GetLanguageType(language string) (langType Type) {
|
||||
langType, _ = languagesType[language]
|
||||
langType, ok := languagesType[language]
|
||||
if !ok {
|
||||
langType = Unknown
|
||||
}
|
||||
|
||||
return langType
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
package slinguist
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var languagesByExtension = map[string][]string{
|
||||
{{range $extension, $languages := . -}}
|
||||
"{{ $extension }}": { {{- $languages | formatStringSlice -}} },
|
||||
{{end -}}
|
||||
}
|
@ -17,7 +17,11 @@ const (
|
||||
|
||||
// GetLanguageType returns the given language's type.
|
||||
func GetLanguageType(language string) (langType Type) {
|
||||
langType, _ = languagesType[language]
|
||||
langType, ok := languagesType[language]
|
||||
if !ok {
|
||||
langType = Unknown
|
||||
}
|
||||
|
||||
return langType
|
||||
}
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
package slinguist
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
type Type int
|
||||
|
||||
const (
|
||||
// Language's type. Either data, programming, markup, prose, or unknown.
|
||||
Unknown Type = iota
|
||||
Data
|
||||
Programming
|
||||
Markup
|
||||
Prose
|
||||
)
|
||||
|
||||
// GetLanguageType returns the given language's type.
|
||||
func GetLanguageType(language string) (langType Type) {
|
||||
langType, _ = languagesType[language]
|
||||
return langType
|
||||
}
|
||||
|
||||
var languagesType = map[string]Type{
|
||||
{{range $language, $type := . -}}
|
||||
"{{ $language }}": {{ $type -}},
|
||||
{{end -}}
|
||||
}
|
6
type.go
6
type.go
@ -17,7 +17,11 @@ const (
|
||||
|
||||
// GetLanguageType returns the given language's type.
|
||||
func GetLanguageType(language string) (langType Type) {
|
||||
langType, _ = languagesType[language]
|
||||
langType, ok := languagesType[language]
|
||||
if !ok {
|
||||
langType = Unknown
|
||||
}
|
||||
|
||||
return langType
|
||||
}
|
||||
|
||||
|
@ -29,4 +29,7 @@ func (s *TSuite) TestGetLanguageType(c *C) {
|
||||
|
||||
langType = GetLanguageType("Textile")
|
||||
c.Assert(langType, Equals, Prose)
|
||||
|
||||
langType = GetLanguageType("Whatever")
|
||||
c.Assert(langType, Equals, Unknown)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user