2024-09-26 15:34:35 +02:00
|
|
|
package greetings
|
|
|
|
|
2024-09-26 15:44:26 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
2024-09-26 15:34:35 +02:00
|
|
|
|
|
|
|
// Hello returns a greeting for the named person.
|
2024-09-26 15:53:25 +02:00
|
|
|
func Hello(name string) (string, error) {
|
2024-09-26 15:44:26 +02:00
|
|
|
// If no name was given, return an error with a message.
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("empty name")
|
|
|
|
}
|
|
|
|
|
2024-09-26 15:34:35 +02:00
|
|
|
// Return a greeting that embeds the name in a message.
|
|
|
|
message := fmt.Sprintf("Hi, %v. Welcome!", name)
|
2024-09-26 15:44:26 +02:00
|
|
|
return message, nil
|
2024-09-26 15:34:35 +02:00
|
|
|
}
|