From b2d0e5935be8b1adce39cda7c868160a928077bc Mon Sep 17 00:00:00 2001 From: Manuel Carmona Date: Fri, 7 Jul 2017 09:59:56 +0200 Subject: [PATCH] documented safe value and plural functions in the README --- README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8b43715..37a3a7c 100644 --- a/README.md +++ b/README.md @@ -22,15 +22,15 @@ Examples -------- ```go -lang, _ := GetLanguageByExtension("foo.go") +lang, safe := enry.GetLanguageByExtension("foo.go") fmt.Println(lang) // result: Go -lang, _ = GetLanguageByContent("foo.m", "") +lang, safe := enry.GetLanguageByContent("foo.m", "") fmt.Println(lang) // result: Matlab -lang, _ = GetLanguageByContent("bar.m", "") +lang, safe := enry.GetLanguageByContent("bar.m", "") fmt.Println(lang) // result: Objective-C @@ -38,6 +38,21 @@ fmt.Println(lang) lang := enry.GetLanguage("foo.cpp", "") ``` +Note the returned boolean value "safe" is set either to true, if there is only one possible language detected or, to false otherwise. + +To get a list of possible languages for a given file, you can use the plural version of the detecting functions. + +```go +langs := enry.GetLanguages("foo.h", "") +// result: []string{"C++", "C"} + +langs := enry.GetLanguagesByExtension("foo.asc", "", nil) +// result: []string{"AGS Script", "AsciiDoc", "Public Key"} + +langs := enry.GetLanguagesByFilename("Gemfile", "", []string{}) +// result: []string{"Ruby"} +``` + CLI -----------------