37 lines
580 B
Go
37 lines
580 B
Go
package helloworld
|
|
|
|
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", ""))
|
|
}
|