github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/readability/nil_interface_en.go (about) 1 // +build OMIT 2 3 package main // OMIT 4 5 import "fmt" 6 7 type I interface { 8 Key() string 9 Value() string 10 } 11 type S struct{ I } // S has method sets of I. 12 func (s S) Key() string { return "type S" } 13 14 func main() { 15 var s S 16 fmt.Println("key", s.Key()) 17 fmt.Println(s.Value()) // runtime error: invalid memory address or nil pointer deference // HL 18 }