Slide 1

Slide 1 text

#goconnect golangci-lint との つきあいかた 株式会社ビットキー / おーたかこーたろー 2025.02.19 Go Connect #5 The Go gopher was designed by Renée French.

Slide 2

Slide 2 text

#goconnect golangci-lint は活⽤しているでしょうか? https://golangci-lint.run/

Slide 3

Slide 3 text

#goconnect 静的解析を束ねるツール‧ランナー https://golangci-lint.run/

Slide 4

Slide 4 text

#goconnect どんな運⽤をしているでしょうか?

Slide 5

Slide 5 text

#goconnect コードをクリーンにするひとつの⼿段

Slide 6

Slide 6 text

#goconnect 正解はないと思いますが ひとつの選択肢として紹介します!

Slide 7

Slide 7 text

Outline #goconnect 1. Linters の設定 2. golangci-lint のバージョン管理 3. CI の⼯夫 4. 今後の展望

Slide 8

Slide 8 text

Outline #goconnect 1. Linters の設定 2. golangci-lint のバージョン管理 3. CI の⼯夫 4. 今後の展望

Slide 9

Slide 9 text

#goconnect golangci-lint は静的解析を取捨選択して運⽤

Slide 10

Slide 10 text

Copyright © Bitkey Inc. All rights reserved. #goconnect linters の設定⽅針 デフォルト enable-all /disable disable-all /enable

Slide 11

Slide 11 text

#goconnect デフォルト errcheck gosimple govet ineffassign staticcheck unused asasalint asciicheck bidichk bodyclose canonicalheader containedctx copyloopvar cyclop decorder depguard dogsled dupl dupword durationcheck err113 errchkjson errname errorlint exhaustive exhaustruct exptostd fatcontext forbidigo ... ※ 2025.02 現在 110 種類の Linters が存在

Slide 12

Slide 12 text

Copyright © Bitkey Inc. All rights reserved. #goconnect enable-all/disable ※ 2025.02 現在 110 種類の Linters が存在 gosimple govet ineffassign staticcheck unused asasalint asciicheck bidichk canonicalheader containedctx copyloopvar cyclop decorder depguard dogsled dupl dupword durationcheck errchkjson errname errorlint exhaustive exhaustruct exptostd fatcontext ... err113 bodyclose errcheck forbidigo

Slide 13

Slide 13 text

Copyright © Bitkey Inc. All rights reserved. #goconnect disable-all/enable ※ 2025.02 現在 110 種類の Linters が存在 errcheck gosimple govet ineffassign unused asciicheck bidichk bodyclose canonicalheader containedctx copyloopvar cyclop decorder depguard dogsled dupl dupword durationcheck err113 errname errorlint exhaustive exhaustruct fatcontext forbidigo ... staticcheck cyclop errchkjson asasalint exptostd

Slide 14

Slide 14 text

Copyright © Bitkey Inc. All rights reserved. #goconnect 私たちの選択 ※ ビットキーではいくつか Go を採⽤しているチームがあるが他チームはこの限りでない デフォルト enable-all /disable disable-all /enable

Slide 15

Slide 15 text

#goconnect 最新の Go の書き⽅に対応 & 学習のきっかけ

Slide 16

Slide 16 text

#goconnect Go 1.22 対応 v1.57.0 で追加 for ⽂の統⼀ https://github.com/ckaznocha/intrange

Slide 17

Slide 17 text

#goconnect Before After for ⽂の統⼀

Slide 18

Slide 18 text

#goconnect Go 1.22 対応 v1.57.0 で追加 tt := tt が不要 https://github.com/karamaru-alpha/copyloopvar

Slide 19

Slide 19 text

#goconnect Before After tt := tt が不要

Slide 20

Slide 20 text

#goconnect 値 or ポインタ v1.62.0 で追加 レシーバの統⼀ https://github.com/raeperd/recvcheck

Slide 21

Slide 21 text

#goconnect Before After レシーバの統⼀

Slide 22

Slide 22 text

#goconnect https://dave.cheney.net/2015/11/18/wednesday-pop-quiz-spot-the-race ? データ競合が発⽣ ? ?

Slide 23

Slide 23 text

Outline #goconnect 1. Linters の設定 2. golangci-lint のバージョン管理 3. CI の⼯夫 4. 今後の展望

Slide 24

Slide 24 text

Copyright © Bitkey Inc. All rights reserved. #goconnect ※ ビットキーではいくつか Go を採⽤しているチームがあるが他チームはこの限りでない 私たちの選択 再掲 デフォルト enable-all /disable disable-all /enable

Slide 25

Slide 25 text

Copyright © Bitkey Inc. All rights reserved. #goconnect デフォルト enable-all /disable disable-all /enable 再掲 ※ ビットキーではいくつか Go を採⽤しているチームがあるが他チームはこの限りでない 私たちの選択 最新版 を 使う必要 がある

Slide 26

Slide 26 text

#goconnect ばーじょん... golangci-lint のバージョン管理どうしてますか?

Slide 27

Slide 27 text

Copyright © Bitkey Inc. All rights reserved. #goconnect tools.go × _ import Makefile go tool command aqua バージョン管理ツール New ! etc …

Slide 28

Slide 28 text

#goconnect 私たちはどうしているか ... ?

Slide 29

Slide 29 text

Copyright © Bitkey Inc. All rights reserved. #goconnect tools.go × _ import Makefile go tool command aqua etc … バージョン管理ツール New ! NO

Slide 30

Slide 30 text

#goconnect 常に最新版を実⾏するスタイル

Slide 31

Slide 31 text

Copyright © Bitkey Inc. All rights reserved. #goconnect PR 作成時 に実⾏ CI は latest を指定 各開発者は 対応時に最新へ

Slide 32

Slide 32 text

Copyright © Bitkey Inc. All rights reserved. #goconnect メリット golangci-lint のバージョン更新が不要

Slide 33

Slide 33 text

Copyright © Bitkey Inc. All rights reserved. #goconnect デメリット PR作成時に意図しない箇所が golangci-lint の修正対象となる

Slide 34

Slide 34 text

Outline #goconnect 1. Linters の設定 2. golangci-lint のバージョン管理 3. CI の⼯夫 4. 今後の展望

Slide 35

Slide 35 text

Copyright © Bitkey Inc. All rights reserved. #goconnect これまでのPR作成時の実⾏ + 定期実⾏

Slide 36

Slide 36 text

Copyright © Bitkey Inc. All rights reserved. #goconnect 毎朝定期実⾏! 失敗時は 修正⽤ PR を ⾃動で作成! 失敗時は Slack 通知!

Slide 37

Slide 37 text

#goconnect

Slide 38

Slide 38 text

#goconnect 最新版で実⾏ PRを作成

Slide 39

Slide 39 text

#goconnect https://zenn.dev/otakakot/articles/172ac34ee62582

Slide 40

Slide 40 text

#goconnect PR 作成時の予期せぬ静的解析対応からの解放!

Slide 41

Slide 41 text

Outline #goconnect 1. Linters の設定 2. golangci-lint のバージョン管理 3. CI の⼯夫 4. 今後の展望

Slide 42

Slide 42 text

#goconnect ばーじょん... バージョン管理の検討

Slide 43

Slide 43 text

#goconnect https://tip.golang.org/doc/go1.24#tools

Slide 44

Slide 44 text

#goconnect 試しに導⼊してみたら...

Slide 45

Slide 45 text

#goconnect 依存関係が膨⼤に...

Slide 46

Slide 46 text

#goconnect https://zenn.dev/otakakot/articles/39c104193e7dad

Slide 47

Slide 47 text

#goconnect https://zenn.dev/otakakot/articles/39c104193e7dad go tool で golangci-lint は 管理しない⽅がよいのかも

Slide 48

Slide 48 text

No content