summaryrefslogtreecommitdiff
path: root/go/bob/bob.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-25 03:13:39 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-25 03:13:39 +0200
commit509c5063d66e8bbef4ec1def1c99c318be51aceb (patch)
treeafc811c4781a4e317043e2a0237499defc168044 /go/bob/bob.go
Initial import
Diffstat (limited to 'go/bob/bob.go')
-rw-r--r--go/bob/bob.go32
1 files changed, 32 insertions, 0 deletions
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."
+ }
+}