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
cmp.Or に感動した
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Kotaro Otaka
November 20, 2024
Programming
1.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
cmp.Or に感動した
The Go gopher was designed by Renée French.
https://golangtokyo.connpass.com/event/331510/
Kotaro Otaka
November 20, 2024
More Decks by Kotaro Otaka
See All by Kotaro Otaka
Go で「見つからなかった」をどう表現するか
otakakot
0
34
actions/setup-go 完全に理解した
otakakot
1
130
Vendoring をやめたけどやめたのは正解だったのか
otakakot
0
70
t *testing.T は どこからやってくるの?
otakakot
1
1.2k
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
1.5k
Go で作った CLI ツールにバージョンを埋め込みたい
otakakot
0
260
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
2
670
組込みだけじゃない! TinyGo で始める無料クラウド開発入門
otakakot
1
180
統一感のある Go コードを生成 AI の力で手にいれる
otakakot
1
3.9k
Other Decks in Programming
See All in Programming
Verilogで学ぶCPU自作入門
uyuki234
8
4.2k
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
880
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
1k
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
1
170
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
200
Event is what happens
moro
2
1.2k
R8 の設定見直しでアプリサイズ削減
andpad
0
220
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
120
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
Simple Storage Service(S3) is not simple
iwatsukayura
0
310
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
230
Featured
See All Featured
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Are puppies a ranking factor?
jonoalderson
2
4.1k
WENDY [Excerpt]
tessaabrams
14
40k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
Embracing the Ebb and Flow
colly
88
5.2k
How to Talk to Developers About Accessibility
jct
2
590
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
KATA
mclloyd
PRO
35
16k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Transcript
おーたかこーたろー @otakakot The Go gopher was designed by Renée French.
cmp.Or に感動した 2024.11.20 golang.tokyo #37
cmp.Or 関数をご存知ですか?
Go 標準の cmp パッケージの関数 google/go-cmp
Kotaro Otaka おーたかこーたろー Web Engineer 新卒入社 Hello Golang! Web Engineer
株式会社ビットキー 2020.04 2021.04 2022.11 @otakakot
https://speakerdeck.com/otakakot/free-go-server-development-recommendations https://zenn.dev/otakakot/articles/9e9269a87aafeb
アジェンダ 01. cmp.Or とは 02. cmp.Or の使い方 03. cmp.Or の実装
04. cmp.Or にヒントを得て
アジェンダ 01. cmp.Or とは 02. cmp.Or の使い方 03. cmp.Or の実装
04. cmp.Or にヒントを得て
Go 1.22 で登場した関数 cmp.Or とは ref: https://go.dev/doc/go1.22
アジェンダ 01. cmp.Or とは 02. cmp.Or の使い方 03. cmp.Or の実装
04. cmp.Or にヒントを得て
cmp.Or の使い方 ref: https://pkg.go.dev/cmp#Or
Go 1.22 リリースパーティ 2023.03.18 開催 https://gocon.connpass.com/event/310606/ https://youtu.be/0nsryM4X-0I?t=1038 GoのマスコットのGopherの原作者はRenee Frenchさんです Gopherのイラストはtenntennさんによるものです
cmp.Or の使い方
アジェンダ 01. cmp.Or とは 02. cmp.Or の使い方 03. cmp.Or の実装
04. cmp.Or にヒントを得て
cmp.Or 関数の実装 ref: https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/cmp/cmp.go
アジェンダ 01. cmp.Or とは 02. cmp.Or の使い方 03. cmp.Or の実装
04. cmp.Or にヒントを得て
nil に対して似たようなことできそう
• NilOr … 最初にヒットした Not nil な値を返す • NilDef …
nil だったら default 値を返す • NilZero … nil だったら zero 値を返す リポジトリ https://github.com/otakakot/nilx nilx という nil に対する便利関数
最初にヒットした Not nil な値を返す
最初にヒットした Not nil な値を返す ~ 使い方 ~
最初にヒットした Not nil な値を返す
最初にヒットした Not nil な値を返す ~ 使い方 ~
nil だったら default 値を返す
nil だったら default 値を返す ~ 使い方 ~
nil だったら zero 値を返す
nil だったら zero 値を返す ~ 使い方 ~
雑感 • NilOr で事足りるが名前をつけて使い方を明確化 ◦ NilDef ◦ NilZero • 戻り値を値にするかポインタにするか
◦ 安全に倒すために値を返却
ぱっと思いつきそうではある
ライブラリやほかにもアイデア を知っていたら教えてください!
おーたかこーたろー @otakakot The Go gopher was designed by Renée French.
cmp.Or に感動した 2024.11.20 golang.tokyo #37