hello %s
This commit is contained in:
parent
aa8ec804e9
commit
f13632e425
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 fmt.Sprintf("Hello %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println(Hello())
|
fmt.Println(Hello("Mary"))
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package main
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestHello(t *testing.T) {
|
func TestHello(t *testing.T) {
|
||||||
got := Hello()
|
got := Hello("Jason")
|
||||||
exp := "Hello world"
|
exp := "Hello Jason"
|
||||||
if got != exp {
|
if got != exp {
|
||||||
t.Errorf("got %q expected %q", got, exp)
|
t.Errorf("got %q expected %q", got, exp)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user