Created
January 13, 2017 19:28
-
-
Save dgryski/31ef7c8d40f804ab1d91f0c47728e928 to your computer and use it in GitHub Desktop.
guru
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dgryski@kamek[w] \ʕ◔ϖ◔ʔ/ > cat main.go | |
package main | |
import "log" | |
type X struct { | |
body string | |
} | |
type Message interface { | |
Body() string | |
} | |
type LoggableMessage interface { | |
log() | |
} | |
func (x *X) Body() string { | |
return x.body | |
} | |
func (x *X) log() { | |
log.Printf("logging body: %q\n", x.body) | |
} | |
func send(m Message) { | |
log.Printf("sending: %v", m.Body()) | |
if l, ok := m.(LoggableMessage); ok { | |
l.log() | |
} | |
} | |
func main() { | |
x := X{body: "hello, world"} | |
send(&x) | |
} | |
<dgryski@kamek[w] \ʕ◔ϖ◔ʔ/ > guru -scope github.com/dgryski/w callers main.go:#193 | |
/home/dgryski/Dropbox/GITS/gocode/src/github.com/dgryski/w/main.go:21:13: (*github.com/dgryski/w.X).log is called from these 1 sites: | |
/home/dgryski/Dropbox/GITS/gocode/src/github.com/dgryski/w/main.go:29:8: dynamic method call from github.com/dgryski/w.send | |
<dgryski@kamek[w] \ʕ◔ϖ◔ʔ/ > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment