github.com/nibnait/go-learn@v0.0.0-20220227013611-dfa47ea6d2da/src/test/chapter/ch2/15_interface_test.go (about) 1 package ch2 2 3 import "testing" 4 5 type Programmer1 interface { 6 writeHelloWorld() string 7 } 8 9 type GoProgrammer1 struct { 10 } 11 12 func (g *GoProgrammer1) writeHelloWorld() string { 13 return "fmt.Println(\"hello world\")" 14 } 15 16 func TestClient(t *testing.T) { 17 var p Programmer1 18 p = new(GoProgrammer1) 19 t.Log(p.writeHelloWorld()) 20 }