wantedly / gophers-code-reading-party

ʕ ◔ϖ◔ʔ
2 stars 2 forks source link

20191211 Gophers Code Reading Party #37

Open izumin5210 opened 4 years ago

izumin5210 commented 4 years ago

201912111900 ~ @ 5F Lounge, Wantedly, Inc. Tokyo HQ

WHY

Go 完全に理解したい

WHAT

とりあえず読みたいものを書いていきましょう!

izumin5210 commented 4 years ago

https://github.com/pkg/expect

t もメッセージも渡してないのに、魔法の力でなんか良い感じにアサーションしてエラーメッセージ出してくれるらしい

func TestOpenFile(t *testing.T) {
        f, err := os.Open("notfound")
        expect.Nil(err)
        err = f.Close()
        expect.True(err == nil)
}
% go test
--- FAIL: TestOpenFile (0.00s)
    check_test.go:12: expected: <nil>, got: open notfound: no such file or directory
izumin5210 commented 4 years ago

前とばしちゃったやつ

[Go] 構造体オブジェクト初期化時にフィールド名を指定することを強制する #golangjp - My External Storage

これ知らなかった。^ 8月の記事なので僕が気づかなかっただけで読んでる人いそう

https://github.com/wantedly/gophers-code-reading-party/issues/36#issuecomment-560332601

izumin5210 commented 4 years ago

pkg/expect

実験 https://play.golang.org/p/ok8NEDG9yPH

runtime.Stack で取り出したトレースから t.tRunner(... を探して、ポインタを引っこ抜いている 邪悪w