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
package main | |
// Given an interface | |
type I interface { | |
Func() | |
} | |
// And another interface | |
type I2 interface { | |
Another() |
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
> go tool pprof 'localhost:6060/debug/pprof/my_experiment_thing?debug=1' | |
Fetching profile from http://localhost:6060/debug/pprof/my_experiment_thing?debug=1 | |
Saved profile in /Users/.../pprof/pprof.localhost:6060.my_experiment_thing.007.pb.gz | |
Entering interactive mode (type "help" for commands) | |
(pprof) top30 | |
6 of 6 total ( 100%) | |
flat flat% sum% cum cum% | |
6 100% 100% 6 100% main.usesAResource | |
0 0% 100% 2 33.33% main.main.func3 | |
0 0% 100% 2 33.33% net/http.(*ServeMux).ServeHTTP |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
_ "net/http/pprof" | |
"os" | |
"runtime/pprof" | |
"sync/atomic" |
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
my_experiment_thing profile: total 6 | |
4 @ 0x2245 0x5d961 | |
# 0x2244 main.usesAResource+0x64 /Users/.../pproftest.go:64 | |
2 @ 0x2245 0x2574 0x9c184 0x9d56f 0x9df7d 0x9aa07 0x5d961 | |
# 0x2244 main.usesAResource+0x64 /Users/.../pproftest.go:64 | |
# 0x2573 main.main.func3+0x13 /Users/.../pproftest.go:79 | |
# 0x9c183 net/http.HandlerFunc.ServeHTTP+0x43 /usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:1726 | |
# 0x9d56e net/http.(*ServeMux).ServeHTTP+0x7e /usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:2022 | |
# 0x9df7c net/http.serverHandler.ServeHTTP+0x7c /usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:2202 |
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
package main | |
import ( | |
"bytes" | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
buf := bytes.Buffer{} |
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
s := Stats{} | |
go s.Loop(ctx) | |
fmt.Println("I started service", s) |
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
type Stats struct { | |
prev runtime.MemStats | |
} | |
func (p *Stats) stats() { | |
ms := runtime.MemStats{} | |
runtime.ReadMemStats(&ms) | |
mallocCount := ms.Mallocs - p.prev.Mallocs | |
fmt.Println("malloc change is", mallocCount) | |
p.prev = ms |
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
package main | |
import ( | |
"app" | |
"store" | |
) | |
func main( { | |
// ./store_main.go:9: cannot use Store literal (type *Store) as type app.Renderable in argument to app.RunApplication: | |
// *Store does not implement app.Renderable (wrong type for RenderPage method) |
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
package app | |
type Totaller interface { | |
Subtotal() float64 | |
} | |
type Renderable interface { | |
RenderPage(t Totaller) | |
} |
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
package news | |
type Totaller interface { | |
Subtotal() float64 | |
} | |
type NewsfeedRenderable struct {} | |
func (n *NewsfeedRenderable) RenderPage(t Totaller) { |