Skip to content

Instantly share code, notes, and snippets.

@takatoshiono
takatoshiono / profile-go-wc.md
Last active September 20, 2016 15:30
go-wc のプロファイリング
@takatoshiono
takatoshiono / go-wc_bench1.md
Created September 18, 2016 21:50
Mac の wc と go-wc を比較する
package main
import (
"fmt"
"sync"
)
type FetchedUrl struct {
url map[string]bool
mux sync.Mutex
package main
import "golang.org/x/tour/tree"
import "fmt"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
var walker func(t *tree.Tree)
walker = func(t *tree.Tree) {
package main
import "golang.org/x/tour/pic"
import "image"
import "image/color"
type Image struct {
width int
height int
}
@takatoshiono
takatoshiono / exercise-rot-reader.go
Last active September 3, 2016 10:09
A Tour of Go: Exercise: rot13Reader, https://go-tour-jp.appspot.com/methods/23
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
// Add a Read([]byte) (int, error) method to MyReader.
func (r MyReader) Read(b []byte) (int, error) {
b[0] = 'A'
return 1, nil
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
package main
import "fmt"
import "strings"
type IPAddr [4]byte
// Add a "String() string" method to IPAddr.
func (ipaddr IPAddr) String() string {
octets := make([]string, 4)
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
var i int
var n [3]int
return func() int {