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
go-exhaustruct linterのすすめ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Shoichi Kaji
February 27, 2026
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
go-exhaustruct linterのすすめ
kamakura.go #8 2026/02/27
Shoichi Kaji
February 27, 2026
More Decks by Shoichi Kaji
See All by Shoichi Kaji
Parallel::Pipesの紹介
skaji
2
1.2k
宿泊予約サイトにおける検索と料金計算の両立
skaji
2
4.3k
昔のGo, 今のGo ~比較, ソート編~
skaji
0
320
Perl Quiz
skaji
0
190
cpm at PerlCon 2019
skaji
0
160
Perl5 Package Manager
skaji
0
810
Internal of cpm
skaji
0
670
How to execute external programs in Perl
skaji
3
760
Writing Perl with w0rp/ale
skaji
0
2.5k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
WCS-LA-2024
lcolladotor
0
900
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
760
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Abbi's Birthday
coloredviolet
4
10k
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
From π to Pie charts
rasagy
1
400
Navigating Weather and Climate Data
rabernat
0
560
Transcript
go-exhaustruct linterͷ͢͢Ί Shoichi Kaji
ҙࣝ package user type Input struct { Name string Age
int } type User struct { Name string Age int } func New(input Input) (*User, error) { // όϦσʔγϣϯͳͲΛ͔·͢ return &User{ Name: input.Name, Age: input.Age, }, nil } user.User͕͋Δͱ͢Δ ͦΕΛ֤ॴͰ͍ͬͯΔ // ༻ॴ1 usr, err := user.New(user.Input{ Name: "Taro", Age: 25, }) // ༻ॴ2 for _, r := range results { u, err := user.New(user.Input{ Name: r.Name, Age: r.Age, }) // ... }
ҙࣝ package user type Input struct { Name string Age
int Address string // Ճʂ } type User struct { Name string Age int Address string } func New(input Input) (*User, error) { // όϦσʔγϣϯͳͲΛ͔·͢ return &User{ Name: input.Name, Age: input.Age, Address: input.Address, }, nil } user.UserʹAddressՃ AddressΛՃ͠ΕΔ😢 // ༻ॴ1 usr, err := user.New(user.Input{ Name: "Taro", Age: 25, Address: "Tokyo", // ͪ͜͜ΌΜͱՃͨ͠ }) // ༻ॴ2 for _, r := range results { u, err := user.New(user.Input{ Name: r.Name, Age: r.Age, // Ε͍ͯΔ... }) // ... }
ҙࣝ • structʹ৽ͨͳϑΟʔϧυΛՃͯ͠ɺgolang উखʹθϩΛิͬͯ͘ΕΔ • ୯ͳΔ"Ε"ͰϑΟʔϧυΛࢦఆ͍ͯ͠ͳͯ͘ ίϯύΠϧΤϥʔʹͳΒͳ͍ • ͜ͷθϩʹҙຯΛݟग़ࣗ͠ಈͰิͬͯ͘ΕΔͷ golangͷ͍͍ͱ͜Ζͱݴ͑Δ͕ɺ໌ࣔతʹॻ
͘ํʹ͍ͨ͠ͱ͖͋Δ
ҙࣝ • ࡢࠓɺΞϓϦέʔγϣϯΛԿʹ͚ͯߏங͢ Δ͜ͱ͕૿͍͑ͯΔ • ͦͷ߹ɺ֤ͷಠཱੑΛߴΊΔͨΊɺಉ͡ structΛ͍ճ͢ͷͰͳ͘ɺ֤ͰstructΛݸ ผʹఆٛ͢Δ͜ͱଟ͍ • ΑͬͯɺstructͷϑΟʔϧυࢦఆ͠Ε͕ى
͖͏ΔՕॴ͕૿͍͑͢
https://github.com/ GaijinEntertainment/ go-exhaustruct
go-exhaustructͱʁ • structͷϑΟʔϧυ͕શͯ໌ࣔతʹॻ͔Ε͍ͯΔ͜ ͱΛ੩తʹݕ͢Δlinter • ઌͷྫͩͱɺҎԼͷΑ͏ʹAddressࢦఆΕΛݕ Ͱ͖Δ👍 • ❯ golangci-lint
run --enable exhaustruct ./... main.go:6:23: user.Input is missing field Address (exhaustruct) usr, err := user.New(user.Input{ ^ 1 issues: * exhaustruct: 1
go-exhaustructͱʁ • ͢Ͱʹgolangci-lintͬͯΔਓenable exhaustructͱ͢Ε Α͍ • ઃఆͰ͍Ζ͍ΖΧελϚΠζࢦఆͰ͖Δ • ࠷ॳؾʹͳΔͱ͜Ζ͚ͩenableʹ͢Δͱಋೖ͍͢͠ •
coreͷpackageignoreʹͯ͠Αͦ͞͏ • ࣮ࡍɺۀΞϓϦέʔγϣϯͷCIʹΈࠐΜͰ͓Γɺgo- exhaustruct༗༻ͩͳͱࢥ͍ͬͯΔ
·ͱΊ • go-exhaustruct linterͷհΛͨ͠ • golangstructͷϑΟʔϧυΛࢦఆ͠ͳͯ͘θϩ Ͱิͬͯ͘ΕΔ͕ɺͦΕ͕ʹͳΔͱ͖͋Δ • ϨΠϠʔυΞʔΩςΫνϟͷ࠾༻Ͱݦஶʹ •
go-exhaustructͰstructͷϑΟʔϧυࢦఆ͠ΕΛ ੩తʹݕͰ͖Δ