2016-12-05から1日間の記事一覧

invalid recursive type XXX

zero valueを設定する際に循環してしまうと無限に再帰してしまい終わらないという話。 例えば以下のような定義はダメ。 自分自身で再帰 type Tree struct { Value int Left Tree Right Tree } もちろん、ポインターにしてあげれば、nilがzero valueになるの…

httptestでmock server的なものを作る方法のメモ

以下の3つが欲しい get post (form) post (json) package m import ( "bytes" "encoding/json" "net/http" "net/http/httptest" "net/url" "testing" "io/ioutil" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testi…