-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.go
More file actions
40 lines (31 loc) · 727 Bytes
/
hello.go
File metadata and controls
40 lines (31 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import "fmt"
const portuguese = "Portuguese"
const french = "French"
const japanese = "Japanese"
const englishHelloPrefix = "Hello, "
const portugueseHelloPrefix = "Olá, "
const frenchHelloPrefix = "Bonjour, "
const japaneseHelloPrefix = "こんにちは, "
func Hello(name, language string) string {
if name == "" {
name = "World"
}
return greetingPrefix(language) + name
}
func greetingPrefix(language string) (prefix string) {
switch language {
case french:
prefix = frenchHelloPrefix
case portuguese:
prefix = portugueseHelloPrefix
case japanese:
prefix = japaneseHelloPrefix
default:
prefix = englishHelloPrefix
}
return
}
func main() {
fmt.Println(Hello("Chloé", "French"))
}