From 509c5063d66e8bbef4ec1def1c99c318be51aceb Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 25 Aug 2016 03:13:39 +0200 Subject: Initial import --- go/bob/bob.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 go/bob/bob.go (limited to 'go/bob/bob.go') diff --git a/go/bob/bob.go b/go/bob/bob.go new file mode 100644 index 0000000..129c0aa --- /dev/null +++ b/go/bob/bob.go @@ -0,0 +1,32 @@ +package bob + +import ( + "strings" + "unicode" +) + +const testVersion = 2 + +func Hey(s string) string { + s = strings.TrimSpace(s) + var hasUpper bool + var hasLower bool + for _, r := range s { + switch { + case unicode.IsUpper(r): + hasUpper = true + case unicode.IsLower(r): + hasLower = true + } + } + switch { + case hasUpper && !hasLower: + return "Whoa, chill out!" + case strings.HasSuffix(s, "?"): + return "Sure." + case len(s) == 0: + return "Fine. Be that way!" + default: + return "Whatever." + } +} -- cgit v1.2.3