basebank / gophers-code-reading-party

Gophers Code Reading Party records
18 stars 1 forks source link

20220203 Gophers Code Reading Party #21

Closed budougumi0617 closed 1 year ago

budougumi0617 commented 2 years ago

15:00~16:00 @ Zoom, BASE BANK, Inc.

参加者

@daisuzu @budougumi0617 @glassmonkey

お題

ネタ

ネタがなかったら proposal: review meeting minutes をみてみよう!
https://github.com/golang/go/issues/33502

budougumi0617 commented 2 years ago

Stripe + Firestore + Goによるサブスクリプション機能の構築(実践編) https://note.com/ogiogi93/n/na35ad141101a

stripe apiの実装評判いいので読んでもいいかも

budougumi0617 commented 2 years ago

https://twitter.com/Linda_pp/status/1485233205188116480 https://dominictobias.medium.com/go-is-about-to-get-a-whole-lot-faster-a50c1e7d60b9

ジェネリクスを使って interface{} を避けることで2〜3倍速くなる(こともある)という話らしい

budougumi0617 commented 2 years ago

https://twitter.com/__syumai/status/1486135009262313473 https://kdy1.dev/posts/2022/1/tsc-go

https://twitter.com/__syumai/status/1486135894402912260

tsc uses a lot of shared mutability and many parts depend on garbage collection. Even though I’m an advocate and believer in Rust, it doesn’t feel like the right tool for the job here.

こういうのちゃんと考えて言語選択できる人すごいなあ。

daisuzu commented 2 years ago

2/11(金)にゴリラ.Go #2 やります!

(今日は少し遅れるかもしれません...

budougumi0617 commented 2 years ago

コードリーディングわいわい

budougumi0617 commented 2 years ago

@daisuzu 申し訳ないです、日付間違っていました、先週やったので来週開催(2/3)とさせてください… 🙇 (私としては臨時に今日やってもよい気持ちですが、ちょうど別MTGも入っていました 😇

daisuzu commented 2 years ago

了解です 👍

budougumi0617 commented 2 years ago

K-V storeの実装。小さいので読みやすいかもしれない。 https://github.com/flower-corp/rosedb

budougumi0617 commented 2 years ago

Goのなぜ問答 https://zenn.dev/nobonobo/articles/9a9f12b27bfde9

budougumi0617 commented 2 years ago

https://tech.tier4.jp/entry/2022/02/02/160000 知らなかった

budougumi0617 commented 2 years ago

80行のDNSリゾルバー https://jvns.ca/blog/2022/02/01/a-dns-resolver-in-80-lines-of-go/

net/httpパッケージとか読む前の肩慣らしによいかな。。。?

budougumi0617 commented 2 years ago

SO_REUSEADDR / SO_REUSEPORT を使ったストリーミング配信サーバの無停止アップデート(Hot Deploy)

https://tech.mirrativ.stream/entry/streaming-server-hotdeploy

budougumi0617 commented 2 years ago

肝心なやつをわすれとったね

https://go.dev/blog/go1.18beta2

daisuzu commented 2 years ago

2つのtime.Timeの差が1秒以下なのを判定するのに

x.Sub(y) <= time.Second

と書いたんですが、↓の方が良いみたいですね

!x.Add(time.Second).Before(y)

元ネタ

budougumi0617 commented 2 years ago

おおおー!! うちはいつも EquateApproxTime つかってごまかしてますね。。。w https://pkg.go.dev/github.com/google/go-cmp@v0.5.7/cmp/cmpopts#EquateApproxTime

got := repo.GetUser(ctx, db, id)
// got.Created みたいな time.Timeフィールドの誤差を消したい
if diff := cmp.Diff(got, want, cmpopts.EquateApproxTime(1*time.Second)); diff != "" {

ってか1秒なら 1 * 書く必要ないのか。。。!

budougumi0617 commented 2 years ago

本日の会場です https://zoom.us/j/98968207509?pwd=Y1B3dDJMQS9UdEdpUGxEd1J2UEdmdz09

budougumi0617 commented 2 years ago

byebye constraints pkg.

constraints: remove package https://go-review.googlesource.com/c/go/+/382460/

budougumi0617 commented 2 years ago

普通に変数の型として使うことも想定される未来も含めるとconstraints pkgって名前もどうなん?って話とかいろいろあるらしい

budougumi0617 commented 2 years ago

generics、ライブラリ作ってるひとがこういうのをcomparebleにするとか。。。?

func Equal(x, y interface{}, opts ...Option) bool
budougumi0617 commented 2 years ago

https://twitter.com/Linda_pp/status/1485233205188116480 https://dominictobias.medium.com/go-is-about-to-get-a-whole-lot-faster-a50c1e7d60b9

ジェネリクスを使って interface{} を避けることで2〜3倍速くなる(こともある)という話らしい

webアプリケーション作ってるときはここでサチらないので可読性などを下げてまでgenericsにはしないかな。

https://github.com/DominicTobias/deque/commit/6ebbf656ded60f6e317b016b3df0ef0dd258c7d6 type assertionなくなったりたしかに早くはなりそうって感じのdiffだった。

budougumi0617 commented 2 years ago

https://twitter.com/__syumai/status/1486135009262313473 https://kdy1.dev/posts/2022/1/tsc-go

https://twitter.com/__syumai/status/1486135894402912260

tsc uses a lot of shared mutability and many parts depend on garbage collection. Even though I’m an advocate and believer in Rust, it doesn’t feel like the right tool for the job here.

こういうのちゃんと考えて言語選択できる人すごいなあ。

tsc uses a lot of shared mutability and many parts depend on garbage collection. Even though I’m an advocate and believer in Rust, it doesn’t feel like the right tool for the job here. Using Rust required me to use unsafe too much for this specific project.

budougumi0617 commented 2 years ago

https://zenn.dev/nobonobo/articles/9a9f12b27bfde9

Goにおける例外は非同期の世界に階層化中断機構をもたらしたcontext.Contextであるという意見もある(非同期の世界では広域脱出よりも中断の方が重要)

これはたしかにというかそういう風にみたことがなかったのでなるほどなと思いました

budougumi0617 commented 2 years ago

SO_REUSEADDR / SO_REUSEPORT を使ったストリーミング配信サーバの無停止アップデート(Hot Deploy)

https://tech.mirrativ.stream/entry/streaming-server-hotdeploy

maki-sanがポートしているやつ https://github.com/lestrrat-go/server-starter

budougumi0617 commented 2 years ago

https://github.com/lestrrat-go/server-starter/blob/50cd1900b5bc470635a2b9efee6a141009bef4e2/starter.go#L505

cmd.ExtraFiles = files listnerからもってきたファイルディスクリプタを os/exec#Cmd.ExtraFiles にセットするとそれが立ち上げたプロセスでつかえるコネクションになる。。。? https://pkg.go.dev/os/exec@go1.17.6#Cmd

budougumi0617 commented 2 years ago

実行されるサブプロセスのほうのサーバーは ListenAll 関数を使えば環境設定に指定されたファイルディスクリプタの番号でコネクションをはるので、 cmd.ExtraFiles 経由で親のファイルディスクリプタを使うって感じだった。

https://pkg.go.dev/os#NewFile https://pkg.go.dev/net#FileListener

func NewFile(fd uintptr, name string) *File
func FileListener(f *os.File) (ln Listener, err error)

https://github.com/lestrrat-go/server-starter/blob/50cd1900b5bc470635a2b9efee6a141009bef4e2/listener/listener.go#L150-L170