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