Move to subfolder
This commit is contained in:
36
hello/hello.go
Normal file
36
hello/hello.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
spanish = "Spanish"
|
||||
french = "French"
|
||||
englishHelloPrefix = "Hello, "
|
||||
spanishHelloPrefix = "Hola, "
|
||||
frenchHelloPrefix = "Bonjour, "
|
||||
)
|
||||
|
||||
func Hello(name, language string) string {
|
||||
if name == "" {
|
||||
name = "World"
|
||||
}
|
||||
|
||||
prefix := greetingPrefix(language)
|
||||
return prefix + 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("Hoborg", ""))
|
||||
}
|
||||
Reference in New Issue
Block a user