hello %s
This commit is contained in:
		
							
								
								
									
										6
									
								
								hello.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								hello.go
									
									
									
									
									
								
							@ -2,10 +2,10 @@ package main
 | 
			
		||||
 | 
			
		||||
import "fmt"
 | 
			
		||||
 | 
			
		||||
func Hello() string {
 | 
			
		||||
	return "Hello world"
 | 
			
		||||
func Hello(name string) string {
 | 
			
		||||
	return fmt.Sprintf("Hello %s", name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	fmt.Println(Hello())
 | 
			
		||||
	fmt.Println(Hello("Mary"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,8 +3,8 @@ package main
 | 
			
		||||
import "testing"
 | 
			
		||||
 | 
			
		||||
func TestHello(t *testing.T) {
 | 
			
		||||
	got := Hello()
 | 
			
		||||
	exp := "Hello world"
 | 
			
		||||
	got := Hello("Jason")
 | 
			
		||||
	exp := "Hello Jason"
 | 
			
		||||
	if got != exp {
 | 
			
		||||
		t.Errorf("got %q expected %q", got, exp)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user