greetings/greetings.go
Chris Cowley a5ec44b1f1 oops
2024-09-26 15:53:25 +02:00

18 lines
417 B
Go

package greetings
import (
"errors"
"fmt"
)
// Hello returns a greeting for the named person.
func Hello(name string) (string, error) {
// 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, nil
}