2023-09-29 11:05:01 -04:00
|
|
|
package helloworld
|
2023-09-29 10:07:31 -04:00
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
2023-09-29 11:03:02 -04:00
|
|
|
const (
|
|
|
|
french = "French"
|
|
|
|
spanish = "Spanish"
|
|
|
|
|
|
|
|
englishHelloPrefix = "Hello, "
|
|
|
|
frenchHelloPrefix = "Bonjour, "
|
|
|
|
spanishHelloPrefix = "Hola, "
|
|
|
|
)
|
2023-09-29 10:07:31 -04:00
|
|
|
|
2023-09-29 10:25:17 -04:00
|
|
|
func Hello(name string, language string) string {
|
2023-09-29 10:15:35 -04:00
|
|
|
if name == "" {
|
|
|
|
name = "World"
|
|
|
|
}
|
|
|
|
|
2023-09-29 11:03:02 -04:00
|
|
|
return greetingPrefix(language) + name
|
|
|
|
}
|
2023-09-29 10:25:17 -04:00
|
|
|
|
2023-09-29 11:03:02 -04:00
|
|
|
func greetingPrefix(language string) (prefix string) {
|
2023-09-29 10:25:17 -04:00
|
|
|
switch language {
|
|
|
|
case french:
|
|
|
|
prefix = frenchHelloPrefix
|
|
|
|
case spanish:
|
|
|
|
prefix = spanishHelloPrefix
|
2023-09-29 11:03:02 -04:00
|
|
|
default:
|
|
|
|
prefix = englishHelloPrefix
|
2023-09-29 10:25:17 -04:00
|
|
|
}
|
2023-09-29 11:03:02 -04:00
|
|
|
return
|
2023-09-29 10:07:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2023-09-29 10:25:17 -04:00
|
|
|
fmt.Println(Hello("world", ""))
|
2023-09-29 10:07:31 -04:00
|
|
|
}
|