37 lines
574 B
Go
37 lines
574 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
french = "French"
|
|
spanish = "Spanish"
|
|
|
|
englishHelloPrefix = "Hello, "
|
|
frenchHelloPrefix = "Bonjour, "
|
|
spanishHelloPrefix = "Hola, "
|
|
)
|
|
|
|
func Hello(name string, language string) string {
|
|
if name == "" {
|
|
name = "World"
|
|
}
|
|
|
|
return greetingPrefix(language) + name
|
|
}
|
|
|
|
func greetingPrefix(language string) (prefix string) {
|
|
switch language {
|
|
case french:
|
|
prefix = frenchHelloPrefix
|
|
case spanish:
|
|
prefix = spanishHelloPrefix
|
|
default:
|
|
prefix = englishHelloPrefix
|
|
}
|
|
return
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println(Hello("world", ""))
|
|
}
|