// 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 + "!" }