basebank / gophers-code-reading-party

Gophers Code Reading Party records
18 stars 1 forks source link

20210527 Gophers Code Reading Party #4

Closed budougumi0617 closed 1 year ago

budougumi0617 commented 3 years ago

5月第2回目のコードリーディングパーティです!

5月 27日 (木曜日)⋅午後5:00~6:00@ Zoom, BASE BANK, Inc.

日程調整

https://chouseisan.com/s?h=33d2c9f78b1d4e45836b92d7ba1e4f6c

参加者

お題

budougumi0617 commented 3 years ago

1 でproposalを読んだfuzzingの実装始まったから見ても良いかも。

https://github.com/golang/go/blob/dev.fuzz/src/testing/fuzz.go

budougumi0617 commented 3 years ago

daisuzuさんいつも登録ありがとうございます! 以下の日程にしようと思います!! Goコードリーディングパーティ 5月 27日 (木曜日)⋅午後5:00~6:00

budougumi0617 commented 3 years ago

tenntennさんのfuzzingメモ https://zenn.dev/tenntenn/scraps/34a31252cce4ef

daisuzu commented 3 years ago

https://github.com/rsc/rf

budougumi0617 commented 3 years ago

tenntennさんのrfメモ https://zenn.dev/tenntenn/scraps/7025d8f29b797a

budougumi0617 commented 3 years ago

https://tip.golang.org/doc/go1.17#reflect https://tip.golang.org/pkg/io/fs/#FileInfoToDirEntry

https://twitter.com/tenntenn/status/1397201008397361153 https://twitter.com/tenntenn/status/1397200509879132166

daisuzu commented 3 years ago

https://budougumi0617.github.io/2020/03/27/http-test-in-go/

budougumi0617 commented 3 years ago

ioutil使おうとしてしまったとき、正しいのはどう探すか?

いちど呼んで、実装元へジャンプしてしまうのが一番早いか?(例)

func WriteFile(filename string, data []byte, perm fs.FileMode) error {
    return os.WriteFile(filename, data, perm)
}
budougumi0617 commented 3 years ago

E2E testどうするかな問題 RDBとかデータどう用意する問題 データ用意してもparallel使い始めると気をつけないとflaky起きちゃうしな

// 余談 PlayWright https://www.cresco.co.jp/blog/entry/14335/

budougumi0617 commented 3 years ago

余談 https://twitter.com/inancgumus/status/1397168068955021312

As of Go 1.17: You'll be able to shuffle the execution order of tests & benchmarks:

go test -shuffle=on

budougumi0617 commented 3 years ago

dump済みのdocker imageをcircle ciで立ち上げるmysqlコンテナで使うとかは過去やっていたことはある

emahiro commented 3 years ago

余談: spanner がお安くなってた話 https://cloud.google.com/blog/products/databases/get-more-out-of-spanner-with-granular-instance-sizing

budougumi0617 commented 3 years ago

memo: microserviceはAPIテストレベルに落とし込めてテスタブルなのもありそう。

budougumi0617 commented 3 years ago

15分で rf コマンド読むぞ!

意外(?)とちゃんとドキュメントが書いてある。

https://pkg.go.dev/rsc.io/rf#hdr-Code_addresses

budougumi0617 commented 3 years ago

The simplest code address is the name of a top-level declaration. In this program, those addresses are C, D, F, T, V, and VT.

const (
    C = iota
    D
)

const E = 2.718281828

Eはちがうのかあ


cmd list https://github.com/rsc/rf/blob/ba8df2a1fd6c614eb83c91b6c912067e7eef30b6/rf.go#L49-L60

var cmds = map[string]func(*refactor.Snapshot, string){
    "add":        cmdAdd,
    "sub":        cmdSub,
    "debug":      cmdDebug,
    "inline":     cmdInline,
    "key":        cmdKey,
    "ex":         cmdEx,
    "mv":         cmdMv,
    "rm":         cmdRm,
    "typeassert": cmdTypeAssert,
    "inject":     cmdInject,
}
budougumi0617 commented 3 years ago

mv F:/msg/,$ Greet はどういう動きになるのかな?

https://github.com/rsc/rf/blob/ba8df2a1fd6c614eb83c91b6c912067e7eef30b6/refactor/addr.go#L93

budougumi0617 commented 3 years ago

F 関数の msg から 最後までを Greet メソッドに切り出す、という動きなんだろうか。

$ rf 'mv F:/msg/,$ Greet'
$ diff prog.go prog_org
--- prog.go     2021-05-27 18:02:55.000000000 +0900
+++ prog_org    2021-05-27 18:02:31.000000000 +0900
@@ -14,10 +14,6 @@

 func F(w io.Writer) {
        who := "world"
-       Greet(who, w)
-}
-
-func Greet(who string, w io.Writer) {
        msg := fmt.Sprintf("hello, %v", who)
        fmt.Fprintf(w, "%s\n", msg)
 }
budougumi0617 commented 3 years ago

今日のサマリ