Make the name dynamic
This commit is contained in:
parent
cdfe936ef4
commit
11aa1735e1
6
hello.go
6
hello.go
|
@ -2,10 +2,10 @@ package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func Hello() string {
|
func Hello(name string) string {
|
||||||
return "Hello, world"
|
return "Hello, " + name
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println(Hello())
|
fmt.Println(Hello("Oliver"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package main
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestHello(t *testing.T) {
|
func TestHello(t *testing.T) {
|
||||||
got := Hello()
|
got := Hello("Oliver")
|
||||||
want := "Hello, world"
|
want := "Hello, Oliver"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %q want %q", got, want)
|
t.Errorf("got %q want %q", got, want)
|
||||||
|
|
Loading…
Reference in a new issue