Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
govalid ~ Type-safe validation tool ~
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
sivchari
February 26, 2026
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
govalid ~ Type-safe validation tool ~
sivchari
February 26, 2026
Transcript
20 slides
govalid ~ Type-safe validation tool ~ 02/26/2025 sivchari newmo Inc
The Go gopher was designed by Renée French.
自己紹介 Goのバリデーションツール 既存ツールの問題点 govalid govalidの仕組み まとめ
自己紹介
• sivchari ◦ X/GitHub @sivchari • newmo • Kubernetes maintainer
◦ Cluster API ◦ Kube API Linter • Go Conference メインオーガナイザー
Goのバリデーションツール
• 有名どころは ◦ go-playground/validator • 他にも ◦ asaskevich/govalidator ◦ go-ozzo/ozzo-validation
Goのバリデーションツール
既存ツールの問題点
• reflect依存のバリデーション ◦ reflectは実行時評価なのでパフォーマンスが悪い ◦ structのバリデーションだとネストしてくるとその分評価に時間が かかり、reflectする回数が増える ◦ 大規模リクエストを受ける時にいくらパフォーマンスを上ても致命的 で手動でバリデーションする??
既存ツールの問題点
govalid ~ Type-safe validation tool ~
• https://github.com/sivchari/govalid ◦ 型安全にバリデーションコードを自動生成する ◦ kubebuilderを意識したmarker指向でコード生成を制御する ◦ 公式ページ ▪ https://sivchari.github.io/govalid/
govalid
• ◦ 型安全にバリデーションコードを自動生成する ◦ kubebuilderを意識したmarker指向でコード生成を制御する ◦ 公式ページ ▪ https://sivchari.github.io/govalid/ govalid
• https://sivchari.github.io/govalid/examples/ ◦ コメントベースを書くだけ ◦ 生成された関数に置き換えるだけ ◦ govalidの生成コードは標準パッケージがメイン ▪ 一部依存パッケージあり
govalid
• VS reflection-based validators ◦ 全部のバリデーションツールに対して圧倒的勝利 ▪ https://sivchari.github.io/govalid/benchmarks/ ◦ ex.
▪ go-playgroundのRequiredに約40倍 ▪ URLのような複雑なvalidationでも約5倍 • ozzo-validationに対しては186倍 govalid
govalidの仕組み
• メインはast ◦ markers analyzerがそれぞれのstructやフィールドに紐づいたmarker を集める ◦ govalidがmarker analyzerの結果を受け取りコード生成を行う govalidの仕組み
• ResultとFact ◦ Result ▪ Analyzerが解析した結果をほかAnalyzerに伝搬するための仕組み ▪ ResultTypeで指定できる ◦ Fact
▪ 特定のオブジェクトに対してどのようなことがあったか記録するための 仕組み ▪ FactTypeで指定できる govalidの仕組み
govalidの仕組み
govalidの仕組み • Factはテスト可能 ◦ linterのテストのようにwantで書いて同じ内容が出力されて いるか確認する
まとめ
• reflection-based validationの不満を解決するツールを作ったよ ◦ Goの自動生成の強みを活かしたvalidationツール ◦ Goのvalidationツールのデファクトにしたい ◦ スターと拡散の協力お願いします!!! ◦
まだまだやることたくさんあるので一緒に開発してくれる人を募集し ています!!! まとめ
More Decks by sivchari
See All by sivchari
Big/Tiny GOTOOLCHAIN
sivchari
0
0
go test を速くする
sivchari
4
1.6k
Go1.25 リリースパーティ ~ nil pointer bug ~
sivchari
0
260
Google Developer Group - DevFest Tokyo 2025
sivchari
0
260
Who tests the Tests ?
sivchari
0
300
Go 1.26 リリースパーティ
sivchari
0
350
静的解析 x Kubernetes API Conventions = Kube API Linter ~ ベストプラクティスに準拠したカスタムリソースの作り方と運用 ~
sivchari
0
390
What's GOCACHEPROG ?
sivchari
1
710
gh_extensionsによる快適なOSS生活.pdf
sivchari
0
290
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
390
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
530
The SEO identity crisis: Don't let AI make you average
varn
0
630
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
980
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
340
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Raft: Consensus for Rubyists
vanstee
143
7.9k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
750