bots-garden/hellopublic Fork 0
main
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 0368b85 · on main · k33g · 2h ago
hello.go · 22 lines · 680 BGo Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Package hello greets somebody by name.
package hello

import "strings"

// world is who is greeted when nobody was named. A greeting is the one thing
// that should never come out half-written, and "Hello, !" is what an empty
// name produces if it is passed straight through.
const world = "world"

// Greet returns a greeting for name.
//
// Surrounding whitespace is dropped, so a name that arrives from a form or a
// command line reads the same as one written by hand. A name that is empty, or
// only whitespace, is greeted as the world.
func Greet(name string) string {
	name = strings.TrimSpace(name)
	if name == "" {
		name = world
	}
	return "Hello, " + name + "!"
}