bots-garden/hellopublic Fork 0
v0.1.0
Commits
Clone
git clone https://git.rickub.com/bots-garden/hello.git
git clone ssh://git@rickub.com/bots-garden/hello.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

hello.go · 22 lines · 680 BGo Blame HistoryRaw
📦 Hello 0368b85 k33g 4h ago1// Package hello greets somebody by name.
2package hello
3
4import "strings"
5
6// world is who is greeted when nobody was named. A greeting is the one thing
7// that should never come out half-written, and "Hello, !" is what an empty
8// name produces if it is passed straight through.
9const world = "world"
10
11// Greet returns a greeting for name.
12//
13// Surrounding whitespace is dropped, so a name that arrives from a form or a
14// command line reads the same as one written by hand. A name that is empty, or
15// only whitespace, is greeted as the world.
16func Greet(name string) string {
17 name = strings.TrimSpace(name)
18 if name == "" {
19 name = world
20 }
21 return "Hello, " + name + "!"
22}