diff --git a/greetings.go b/greetings.go index e66d285..301c851 100644 --- a/greetings.go +++ b/greetings.go @@ -1,10 +1,18 @@ package greetings -import "fmt" +import ( + "errors" + "fmt" +) // Hello returns a greeting for the named person. func Hello(name string) string { + // If no name was given, return an error with a message. + if name == "" { + return "", errors.New("empty name") + } + // Return a greeting that embeds the name in a message. message := fmt.Sprintf("Hi, %v. Welcome!", name) - return message + return message, nil }