Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Inve...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
convto
September 13, 2024
Technology
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Investigating How gob Binary Output Changes Across Go Versions
Asakusa.go #3 での発表資料です
convto
September 13, 2024
More Decks by convto
See All by convto
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
0
1
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
3
810
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
700
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
400
MCPと認可まわりの話 / mcp_and_authorization
convto
2
1.7k
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
2.3k
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
610
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
3.5k
みんなでたのしむ math/big / i love math big
convto
0
360
Other Decks in Technology
See All in Technology
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
240
AIで開発は速くなったのに、なぜ現場は楽にならないのか 〜あなたの組織のボトルネックを突き止めるワークショップ〜
jacopen
1
270
プロダクトエンジニアに必要な「いい感じ」に作る能力 〜たくさん作れる時代に、どこまで作るかの決め方〜
jnishime_dresscode
2
1.4k
Microsoft 365 Copilot chat -tekoälypalvelun tietosuojaongelmat
hponka
0
460
データエンジニアリングワークショップ:Auto LoaderとSparkで学ぶデータパイプライン構築
databricksjapan
PRO
0
190
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
180
振り返りこそエンジニアの本領
negima
0
320
多層防御と最⼩権限で実現する、安全なAIエージェント設計パターン
lycorptech_jp
PRO
0
210
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
270
2026/09/10 Spring_Bootから_Jakarta_EE_MicroProfileへの移行
megascus
0
150
現場に行くだけでは足りない——プロダクトエンジニアが業務の流れを捉える観点と、その鍛え方
takumiengineering
0
310
AIで実装は速くなった。なのにプロダクトは速くならない。職能の壁を越えて価値のフローを設計する
nwiizo
6
7.3k
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
What's in a price? How to price your products and services
michaelherold
247
13k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
510
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Done Done
chrislema
186
16k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.2k
The Cult of Friendly URLs
andyhume
79
7k
Designing for Timeless Needs
cassininazir
1
470
Code Review Best Practice
trishagee
74
20k
Transcript
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた 2024/09/13 Asakusa.go #3
自己紹介 @convto 株式会社LayerX所属 (読みはこんぶとです)
gob ってなに? - Go が標準パッケージで実装してる独自のエンコーディング! - 仕様とかくわしく知りたい人はこちらをご覧ください https://speakerdeck.com/convto/understanding-gob-encoding - きょうは
5min LT なので全員完全理解者だと思って話を進めます
ある日知人から以下のタレコミをうける
タレコミ - なんか Go のバージョンによって gob の出力が異なるんだけど - marshal/unmarshal 間の互換性はありそう
- どこで変わったんだろうね
確認してみる
確認してみる
None
cnt: 36 id: -64 cnt: 12 id: 64 cnt: 37
id: -65 cnt: 12 id: 65
なんか typedef / value の id がずれてそう - たしかに出力は変わっている -
id の値が変わっている - id = 65 だと typedef がちょうど 1byte で表現できないため、古い方は ちょっと勿体無い - 先頭 1bit が終端判定、末尾 1bit が正負判定。値が 6bit で収まる なら 1byte で表現できる。65 はちょうどたりない
どこで入った? - 霊感で 1.21 まで比べてみたら 1.23 と一致してた $ diff -s
<(go1.21.0 run main.go) <(go1.23.0 run main.go) Files /dev/fd/11 and /dev/fd/12 are identical - 1.20.1 系では挙動に差がない $ diff -s <(go1.20.1 run main.go) <(go1.20.14 run main.go) Files /dev/fd/11 and /dev/fd/12 are identical - 1.21 に上がる時に入っているはず!
見つけた! https://go-review.googlesource.com/c/go/+/460543/4 /src/encoding/gob/type.go#b184
id ずれた理由 - firstUserId = 64 が定義されてて user 定義の型は id
= 64 から始ま る - とりあえず nextId +1 から確保してたのが止まって 64 から使えるように なったという話っぽい!
スッキリ
知人に伝えて平和が訪れた
感想 - marshal/unmarshal の互換を担保した上で encoded な値が変わるこ とはちょいちょいある - よくあるのはフィールド順番担保されないとか。今回は typeid
が揃わな かった - encoded な値に対して一致するか確認する、みたいな処理は秘孔をつく 可能性があるのでやめておきましょう
ご清聴ありがとうございました