Another refactor

This commit is contained in:
Timothy Warren 2023-09-29 11:03:02 -04:00
parent 2c9a6e3049
commit f39c5778ce

View File

@ -2,27 +2,33 @@ package main
import "fmt"
const french = "French"
const spanish = "Spanish"
const englishHelloPrefix = "Hello, "
const frenchHelloPrefix = "Bonjour, "
const spanishHelloPrefix = "Hola, "
const (
french = "French"
spanish = "Spanish"
englishHelloPrefix = "Hello, "
frenchHelloPrefix = "Bonjour, "
spanishHelloPrefix = "Hola, "
)
func Hello(name string, language string) string {
if name == "" {
name = "World"
}
prefix := englishHelloPrefix
return greetingPrefix(language) + name
}
func greetingPrefix(language string) (prefix string) {
switch language {
case french:
prefix = frenchHelloPrefix
case spanish:
prefix = spanishHelloPrefix
default:
prefix = englishHelloPrefix
}
return prefix + name
return
}
func main() {