2022-01-26 12:52:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
2022-01-26 18:00:00 +00:00
|
|
|
const englishHelloPrefix = "Hello, "
|
2022-01-27 00:16:56 +00:00
|
|
|
const welsh = "Welsh"
|
2022-01-27 00:12:35 +00:00
|
|
|
const welshHelloPrefix = "Helo, "
|
2022-01-26 18:00:00 +00:00
|
|
|
|
2022-01-27 00:11:38 +00:00
|
|
|
func Hello(name string, language string) string {
|
2022-01-26 18:00:00 +00:00
|
|
|
if name == "" {
|
|
|
|
name = "World"
|
|
|
|
}
|
|
|
|
|
2022-01-27 00:22:20 +00:00
|
|
|
return greetingPrefix(language) + name
|
|
|
|
}
|
|
|
|
|
|
|
|
func greetingPrefix(language string) (prefix string) {
|
|
|
|
prefix = englishHelloPrefix
|
2022-01-27 00:19:28 +00:00
|
|
|
|
2022-01-27 00:16:56 +00:00
|
|
|
if language == welsh {
|
2022-01-27 00:19:28 +00:00
|
|
|
prefix = welshHelloPrefix
|
2022-01-27 00:11:38 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 00:22:20 +00:00
|
|
|
return
|
2022-01-26 13:12:15 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 12:52:16 +00:00
|
|
|
func main() {
|
2022-01-27 00:11:38 +00:00
|
|
|
fmt.Println(Hello("Oliver", ""))
|
2022-01-26 12:52:16 +00:00
|
|
|
}
|