ご利用ありがとうございます!
Goの動向を逐一追いかけることはしていませんが、気になったことを調べる時に、GitHub上のissueを検索することが良くある。
https://github.com/golang/go/issues/18831
Example Testに正規表現書けるようにするやつ、却下されていた…。 / “proposal: testing: allow regexps to specify example output · Issue #18831 · golang/go · GitHub” https://t.co/7ONGaeFjsZ
— songmu (@songmu) February 10, 2019
入力をtransformして冒頭にタイムスタンプを付けてくれるライブラリ。
import github.com/Songmu/timestamper
var s transform.Transformer = timestamper.New()
var w io.WriteCloser = transform.NewWriter(os.Stdout, s)
fmt.Fprint(w, "Hello\nWorld!")
// Output:
// 2019-02-11T01:14:54.093021+09:00 Hello
// 2019-02-11T01:14:54.093151+09:00 World!
これを以下のように書きたいわけです。
// Regexp output:
// \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}\+\d{2}:\d{2} Hello
// \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}\+\d{2}:\d{2} World!
前項のissue内の議論で出てきて知った。
math/rand/v2/example_test.go
より
func ExamplePerm() {
for _, value := range rand.Perm(3) {
fmt.Println(value)
}
// Unordered output: 1
// 2
// 0
}
https://github.com/golang/go/issues/4068
os/fsnotify入れようっていう計画が以前はあったのかー / “os/fsnotify: add new package · Issue #4068 · golang/go · GitHub” https://t.co/qU1mmeoxKA
— songmu (@songmu) August 6, 2019
https://github.com/golang/go/issues/43854
これ、Go1.18で入ってたの気づいてなかった。go:embedにhidden filesを含められるようにする仕様。https://t.co/KiADHLFrEu
— songmu (@songmu) May 22, 2022
//go:embed all:
https://github.com/golang/go/issues/13182#issuecomment-239958401
Loggerはinterfaceにすれば良いよねっていうのはrobpike先生がすでに結論付けていたのかhttps://t.co/5SF9q0mBTf
— songmu (@songmu) September 23, 2019
https://github.com/golang/go/issues/25955
sync.Once使うとテストしづらいなーって思ってたけど、ポインター入れ替えればonceし直す事できるんだな / “proposal: sync: add a Reset method for sync.Once · Issue #25955 · golang/go · GitHub” https://t.co/LZS8FadnVq
— songmu (@songmu) December 28, 2019
Use
ponce *sync.Once
, and reset it by writingponce = new(sync.Once)
.
勉強になった
https://github.com/golang/go/issues/7252
Goのregexpのrepeat ({n}) の指定上限が1000なのを知りました。 / “regexp/syntax: document limit of 1000 in {n,m} quantifier forms · Issue #7252 · golang/go” https://t.co/kHdDZlceXu
— songmu (@songmu) January 15, 2022
以下のようにドキュメントされてる。
Implementation restriction: The counting forms x{n,m}, x{n,}, and x{n} reject forms that create a minimum or maximum repetition count above 1000. Unlimited repetitions are not subject to this restriction.
https://github.com/golang/go/issues/26492
go1.14でスタティックビルドのための-staticフラグが入りそうなのか。これでオプションいろいろ悩まなくて良くなるの嬉しいな / “cmd/go: build: add -static flag · Issue #26492 · golang/go · GitHub” https://t.co/PYinf6ih1c
— songmu (@songmu) July 19, 2019
https://github.com/golang/go/issues/37533
-helpのexit codeが0になったやり取りこういう感じかー / “flag: exit 0 when -h or -help invoked but undefined by sding3 · Pull Request #37530 · golang/go · GitHub” https://t.co/sW2HfeBaoc
— songmu (@songmu) July 25, 2020
-h
が明示的に指定された場合にexit codeを0 (正常終了) にする
https://github.com/golang/go/issues/41523
一つ前のissueと関連して、-h / --help
が明示的に指定された時にヘルプ出力先を標準出力に出せるようにするための提案
hoge -h | less
とかやりたい hoge -h 2>&1 | less
とかやるのダルい--help
フラグを明示的に実装すればいいのでは?ということだった日本で唯一病院向けのクラウド型電子カルテ・レセコンシステムを開発・運営しており、日本のDXに向き合っています。
OSS活動を支援してくれると嬉しいです。