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
Shoichi Kaji
February 27, 2026
130
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
310
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
750
Writing Perl with w0rp/ale
skaji
0
2.5k
Featured
See All Featured
The Curse of the Amulet
leimatthew05
3
15k
Ruling the World: When Life Gets Gamed
codingconduct
0
380
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Accessibility Awareness
sabderemane
1
230
Speed Design
sergeychernyshev
33
2.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
690
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
KATA
mclloyd
PRO
35
16k
Balancing Empowerment & Direction
lara
6
1.3k
The Curious Case for Waylosing
cassininazir
1
550
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ͷϑΟʔϧυࢦఆ͠ΕΛ ੩తʹݕͰ͖Δ