learn-go-with-tests/hello.go

22 lines
296 B
Go
Raw Normal View History

2022-01-26 12:52:16 +00:00
package main
import "fmt"
2022-01-26 18:00:00 +00:00
const englishHelloPrefix = "Hello, "
2022-01-27 00:11:38 +00:00
func Hello(name string, language string) string {
if name == "" {
name = "World"
}
2022-01-27 00:11:38 +00:00
if language == "Welsh" {
return "Helo, " + name
}
2022-01-26 18:00:00 +00:00
return englishHelloPrefix + name
2022-01-26 13:12:15 +00:00
}
2022-01-26 12:52:16 +00:00
func main() {
2022-01-27 00:11:38 +00:00
fmt.Println(Hello("Oliver", ""))
2022-01-26 12:52:16 +00:00
}