snip pkg/util/strings dependency

This commit is contained in:
deads2k
2017-01-04 11:28:47 -05:00
parent 38d57e5a71
commit 37c0c14215
5 changed files with 100 additions and 67 deletions

View File

@@ -17,7 +17,6 @@ limitations under the License.
package strings
import (
"fmt"
"path"
"strings"
"unicode"
@@ -48,22 +47,6 @@ func ShortenString(str string, n int) string {
}
}
// GetArticleForNoun returns the article needed for the given noun.
func GetArticleForNoun(noun string, padding string) string {
if noun[len(noun)-2:] != "ss" && noun[len(noun)-1:] == "s" {
// Plurals don't have an article.
// Don't catch words like class
return fmt.Sprintf("%v", padding)
}
article := "a"
if isVowel(rune(noun[0])) {
article = "an"
}
return fmt.Sprintf("%s%s%s", padding, article, padding)
}
// isVowel returns true if the rune is a vowel (case insensitive).
func isVowel(c rune) bool {
vowels := []rune{'a', 'e', 'i', 'o', 'u'}