learn-go-with-tests/helloworld/hello.go
2023-09-29 11:05:01 -04:00

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