This file contains 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
//Put this file in $GOPATH/perfbench/perfbench_test.go | |
//go test -bench . -v perfbench/... | |
// | |
//go version go1.5.1 linux/amd64 | |
// | |
//noop: 0 | |
//var x interface{} = <int8>: 1 | |
//var x interface{} = <*int8>: 0 | |
//var x interface{} = <[]int16>: 1 | |
//var x interface{} = <typedInterface(ptr)>: 0 |
This file contains 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" | |
"math" | |
"os" | |
) | |
func main() { | |
if len(os.Args) != 3 { |
This file contains 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 teewriter | |
type TeeWriter struct { | |
w1 io.Writer | |
w2 io.Writer | |
} | |
func (tw *TeeWriter) Write(p []byte) (n int, err error) { | |
n1, err1 := tw.w1.Write(p) | |
n2, err2 := tw.w2.Write(p) |
This file contains 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
func dump(seen map[reflect.Value]bool, rv reflect.Value) string { | |
if rv.Kind() == reflect.Invalid { | |
return "nil" | |
} | |
if _, ok := seen[rv]; ok { | |
return "SEEN[" + rv.Type().Name() + "]" | |
} | |
seen[rv] = true | |
method := rv.MethodByName("String") |
This file contains 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 fs | |
// indirection techniques in go | |
//BenchmarkDirectFib-12 2000000000 0.13 ns/op | |
//BenchmarkSavePtr-12 30 34612496 ns/op | |
//BenchmarkUseBool-12 1000000000 0.53 ns/op | |
//BenchmarkIface-12 2000000000 0.16 ns/op | |
//ok fs 27.053s | |
import "testing" |
This file contains 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 debug | |
import ( | |
"fmt" | |
"io" | |
) | |
func teeCopy(w1 io.Writer, w2 io.Writer, r io.Reader) (totalN int, err error) { | |
buf := make([]byte, 1024) | |
for { |
This file contains 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
1,"Goroka","Goroka","Papua New Guinea","GKA","AYGA",-6.081689,145.391881,5282,10,"U","Pacific/Port_Moresby" | |
2,"Madang","Madang","Papua New Guinea","MAG","AYMD",-5.207083,145.7887,20,10,"U","Pacific/Port_Moresby" | |
3,"Mount Hagen","Mount Hagen","Papua New Guinea","HGU","AYMH",-5.826789,144.295861,5388,10,"U","Pacific/Port_Moresby" | |
4,"Nadzab","Nadzab","Papua New Guinea","LAE","AYNZ",-6.569828,146.726242,239,10,"U","Pacific/Port_Moresby" | |
5,"Port Moresby Jacksons Intl","Port Moresby","Papua New Guinea","POM","AYPY",-9.443383,147.22005,146,10,"U","Pacific/Port_Moresby" | |
6,"Wewak Intl","Wewak","Papua New Guinea","WWK","AYWK",-3.583828,143.669186,19,10,"U","Pacific/Port_Moresby" | |
7,"Narsarsuaq","Narssarssuaq","Greenland","UAK","BGBW",61.160517,-45.425978,112,-3,"E","America/Godthab" | |
8,"Nuuk","Godthaab","Greenland","GOH","BGGH",64.190922,-51.678064,283,-3,"E","America/Godthab" | |
9,"Sondre Stromfjord","Sondrestrom","Greenland","SFJ","BGSF",67.016969,-50.689325,165,-3,"E","America/Godthab" | |
10,"Thule Air Base","Thule","Greenl |
This file contains 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 ( | |
"encoding/binary" | |
"encoding/hex" | |
"flag" | |
"fmt" | |
"log" | |
) |
This file contains 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
<script> | |
window.addEventListener('message', function(event) { | |
console.log('iframe: Got postmessage in origin ' + location.origin + ' from origin: ' + event.origin + '(' + event.data + ')'); | |
}); | |
window.addEventListener('dispatchToIframe', function() { | |
console.log('iframe: Got dispatchEvent() in origin ' + location.origin + '(from index.html)'); | |
}); | |
setTimeout(function() { | |
window.dispatchEvent(new CustomEvent('dispatchFromIframe')); |
This file contains 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" | |
"io/ioutil" | |
"unicode" | |
"strings" | |
) | |
const noRepeatFirstLetter = true |