Move from learn-go-with-tests
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
18bde5d382
commit
b7c3fffbaa
10 changed files with 213 additions and 0 deletions
29
learn-go-with-tests/hello.go
Normal file
29
learn-go-with-tests/hello.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
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