Testing in Go
This commit is contained in:
parent
06a7e9a858
commit
55b8428d2a
3 changed files with 61 additions and 2 deletions
26
go/hello.go
26
go/hello.go
|
@ -2,6 +2,28 @@ package main
|
|||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello, World")
|
||||
const englishHelloPrefix = "Hello, "
|
||||
const welsh = "Welsh"
|
||||
const welshHelloPrefix = "Helo, "
|
||||
|
||||
func Hello(name string, language string) string {
|
||||
if name == "" {
|
||||
name = "World"
|
||||
}
|
||||
|
||||
return greetingPrefix(language) + name
|
||||
}
|
||||
|
||||
func greetingPrefix(language string) (prefix string) {
|
||||
prefix = englishHelloPrefix
|
||||
|
||||
if language == welsh {
|
||||
prefix = welshHelloPrefix
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(Hello("Oliver", ""))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue