learn-go-with-tests/hello/hello.go
2023-09-29 10:25:17 -04:00

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", ""))
}