basebank / gophers-code-reading-party

Gophers Code Reading Party records
18 stars 1 forks source link

20210826 Gophers Code Reading Party #10

Closed hgsgtk closed 1 year ago

hgsgtk commented 2 years ago

8/26(木) 14:30〜15:30@ Zoom, BASE BANK, Inc.

日程未定

調整さん https://chouseisan.com/s?h=1871b829632f4c1b89d28abb0d42e52b

参加者

お題

hgsgtk commented 2 years ago

先にGo 1.17 ネタで気になったやつを書くためにissueを増やしてみた

hgsgtk commented 2 years ago

Go 1.17 (次回のネタの先行集めをしてみる)

https://tip.golang.org/doc/go1.17

Pruned module graphs in go 1.17 modules

To facilitate the upgrade to Go 1.17 pruned module graphs, the go mod tidy subcommand now supports a -go flag to set or change the go version in the go.mod file. To convert the go.mod file for an existing module to Go 1.17 without changing the selected versions of its dependencies, run:

humuhumu

https://tip.golang.org/ref/mod#graph-pruning Module graph pruning

Minor changesめっちゃあるな

以降 @hgsgtk 的に気になった内部実装をぽちぽちいれていく

File.WriteStringの最適化

https://tip.golang.org/doc/go1.17#os

The File.WriteString method has been optimized to not make a copy of the input string.

ユーザーとしても参考になりそう

strconvのアルゴリズム

po3rinさんが好きそうな話題が見受けられる

The strconv package now uses Ulf Adams's Ryū algorithm for formatting floating-point numbers. This algorithm improves performance on most inputs and is more than 99% faster on worst-case inputs.

Ulf Adams's Ryū algorithm なにこれたのしそう

https://tip.golang.org/doc/go1.17#strconv

testing.T.SetEnv がきたぜ

The new T.Setenv and B.Setenv methods support setting an environment variable for the duration of the test or benchmark.

うれしいねぇ

https://tip.golang.org/doc/go1.17#testing

time packageの細かすぎて気になった

https://tip.golang.org/doc/go1.17#time

The package now accepts comma "," as a separator for fractional seconds when parsing and formatting time. The following time formats are now accepted:

2006-01-02 14:06:03,999999999 -0700 MST Mon Jan _2 14:06:03,120007 2006 Mon Jan 2 14:06:03,120007 2006

The new constant Layout defines the reference time.

commaオッケーにしたよとかそういう細かすぎて気づかんみたいなやつ好き、にこにこしちゃう

flag packageのエラーハンドリング

https://tip.golang.org/doc/go1.17#flag

Flag declarations now panic if an invalid name is specified.

コードをサクッと読んでふ〜んってする分にはたのしそう

budougumi0617 commented 2 years ago

リリーーーーーーーーーーーす

https://blog.golang.org/go1.17 https://golang.org/doc/go1.17

mattenパイセンの早巡り https://twitter.com/mattn_jp/status/1427423861012787202 zcheeパイセンの早巡り https://twitter.com/_zchee_/status/1427653240825413635

budougumi0617 commented 2 years ago

来週(8/23の週)に開催予定として日程調整を作りました!!! https://chouseisan.com/s?h=1871b829632f4c1b89d28abb0d42e52b

budougumi0617 commented 2 years ago

~8/26(木) 15:00〜16:00 にしましょう!!!!!!!!!!!~

budougumi0617 commented 2 years ago

絶対に参加しないといけないやーつが15:30〜16:00に入っていたので、14:30~15:30(遅刻可能)ってことにさせてください 🙇 🙇 🙇

hgsgtk commented 2 years ago

とりあえず着席

glassmonkey commented 2 years ago

uberたのんで着席

budougumi0617 commented 2 years ago

やるぞ!!

budougumi0617 commented 2 years ago

もう少し増えるかな?人数揃うまでmattnさんたちのツイートを眺めてみる

https://twitter.com/mattn_jp/status/1427426169465413632 tools.go不要になるかもしれない。

go run がバージョン指定できる様になった。安定バージョンでお届けが可能に。

$ go run example​.com/cmd@v1.0.0

daisuzu commented 2 years ago

zoom linkを 🙏

budougumi0617 commented 2 years ago

すいません!忘れてました!

https://zoom.us/j/93464783808?pwd=bzJyQkRnVkdMZ3drNUxmUC9yYUU2QT09

budougumi0617 commented 2 years ago

[余談] https://go.dev/blog/tidy-web

https://blog.golang.org/fuzz-beta

最近blogもgo.devに飛ばされるようになった。

https://go.dev/blog/fuzz-beta

budougumi0617 commented 2 years ago

1.17にアップデートするときの要注意。 https://twitter.com/mattn_jp/status/1427427593955930159

net/url のセミコロンの扱いが変わる。

example?a=1;b=2&c=3

こういうの。これに伴い、net/http でセミコロンを扱う場合には AllowQuerySemicolons を使ってラップする必要がある。

https://pkg.go.dev/net/http@go1.17#AllowQuerySemicolons

budougumi0617 commented 2 years ago

[余談]

go.dev で3rdパーティのライブラリもメソッドなどが追加されたバージョンが見れるようになった。 https://pkg.go.dev/github.com/gorilla/mux#SetURLVars

image

daisuzu commented 2 years ago

↓とか使ってる?? https://pkg.go.dev/golang.org/x/exp@v0.0.0-20210823210606-b36147abdb7c/apidiff

budougumi0617 commented 2 years ago

これみれば仕組みわかるのかな。。。? https://github.com/golang/website

budougumi0617 commented 2 years ago

https://play.golang.org/p/WbuWrQqJjeR すげえええ

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println(time.Now().GoString()) // time.Date(2009, time.November, 10, 23, 0, 0, 0, time.Local)
}
budougumi0617 commented 2 years ago

https://pkg.go.dev/time#Month

月のconstあったんだ

budougumi0617 commented 2 years ago

ISUCON余談ん

http://dsas.blog.klab.org/archives/52191467.html https://blog.agatan.dev/posts/isucon11-qualify interpolateParams 使って動的プレースホルダを云々するとパフォーマンス上がるらしい。

budougumi0617 commented 2 years ago

https://twitter.com/mattn_jp/status/1427435182051659777

go test に -shuffle

あ、そうそう。Go 1.17 から go get で実行バイナリをインストールしようとすると警告が表示される。今後は
$ go install cmd@version
budougumi0617 commented 2 years ago

tests := map[string]structfor name, tt := range tests { すると map を回すようになるので順不同になるハック https://play.golang.org/p/SChUDfSesbj

budougumi0617 commented 2 years ago

https://pkg.go.dev/time#Time.UnixMicro


https://future-architect.github.io/articles/20210820a/

https://pkg.go.dev/sync/atomic#Value CompareAndSwap とか増えてatomicな操作を書きやすくなった!!

budougumi0617 commented 2 years ago

可能性を感じるpkgだ…

https://pkg.go.dev/runtime/metrics#example-Read-ReadingOneMetric https://pkg.go.dev/runtime/metrics#Read

package main

import (
    "fmt"
    "runtime/metrics"
)

func main() {
    // Name of the metric we want to read.
    const myMetric = "/memory/classes/heap/free:bytes"

    // Create a sample for the metric.
    sample := make([]metrics.Sample, 1)
    sample[0].Name = myMetric

    // Sample the metric.
    metrics.Read(sample)

    // Check if the metric is actually supported.
    // If it's not, the resulting value will always have
    // kind KindBad.
    if sample[0].Value.Kind() == metrics.KindBad {
        panic(fmt.Sprintf("metric %q no longer supported", myMetric))
    }

    // Handle the result.
    //
    // It's OK to assume a particular Kind for a metric;
    // they're guaranteed not to change.
    freeBytes := sample[0].Value.Uint64()

    fmt.Printf("free but not released memory: %d\n", freeBytes)
}
budougumi0617 commented 2 years ago

refelctもしやすくなった!!! https://golang.org/doc/go1.17#reflect

budougumi0617 commented 2 years ago

ISUCONでうまくv4.0のバージョンが取れなかったライブラリ https://github.com/plutov/echo-logrus

budougumi0617 commented 2 years ago

うーん、厳しいライブラリだった…nrhd.... https://github.com/plutov/echo-logrus/pull/6/files

budougumi0617 commented 2 years ago

コピればよかったか(OSS利用者としてあるまじき発言)

daisuzu commented 2 years ago

これとか便利です https://github.com/golang/tools/blob/8c34cc9cafff8f13c3f3ed95a11de309752c1c60/internal/xcontext/xcontext.go

budougumi0617 commented 2 years ago

contextからdeadlineを取り消してくれるやつ

budougumi0617 commented 2 years ago

runtime/metrics pkgで自作プロファイラ作れそうだな

budougumi0617 commented 2 years ago

https://pkg.go.dev/runtime/trace もあるで!!

hgsgtk commented 2 years ago

https://twitter.com/__achille__/status/1431014148800802819?s=21

でかいサイズのデータ処理するシステムとかで15%早くなったという話が

hgsgtk commented 2 years ago

https://formulae.brew.sh/formula/go

homebrewにもgo1.17