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
cloning_git_in_go_gophercon_india.pdf
Search
Aditya Mukerjee
February 25, 2017
46
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
cloning_git_in_go_gophercon_india.pdf
Aditya Mukerjee
February 25, 2017
Transcript
19 slides
Cloning Git in Go Aditya Mukerjee Risk & Systems Engineer
at Stripe @chimeracoder
Why write Gitgo? •Git operations from Go applications •Portability •Simplicity
•…why not? @chimeracoder
The dirty secret about Git •Git wasn’t always meant to
be a version control system •Git is a decentralized, userland filesystem for preserving historical state and synchronizing data @chimeracoder
What We’ve Enabled •Backup •Content management •Distributed build systems •Establishing
consensus @chimeracoder
Have you ever seen a “friend’s” computer that looked like
this? @chimeracoder
@chimeracoder 107724969b2af751a1ffd74e3f38d0d76cb8aa55
@chimeracoder commits trees blobs objects
Discovery #1: Layered interfaces are more flexible than union types
@chimeracoder commits trees blobs objects
Bootstrapping Git in Go “We can just use the real
.git directory for our tests, right?” @chimeracoder …nope.
hash(“I love Go”) != hash(“I love Go!”) @chimeracoder Packfiles
Reference: Unpacking Git Packfiles Reference: Implementing Git’s Compression Algorithm in
Go binarydiff(1, 2, 3) 1. “I love Go” 2. “I love Go!” 3. “You love Go, and so do I!” “I love Go” <string 1> + “!”
Discovery #2: Pay attention to interface contracts @chimeracoder zlib data
<arbitrary data> zlib data <arbitrary data>
@chimeracoder type Reader interface { Read(p []byte) (n int, err
error) } Object 1 Object 2 Object 3 Object 4 …
• Discovery #3: Use concurrency to define state machines, and
use channels for the input/output @chimeracoder f1 f3 f2 g g1 if f g2
• Discovery #4: Treat errors as values, and ask how
they behave @chimeracoder httpdir.Open() ParsePackfile() GitFetch()
• Discovery #5: Well-architected interfaces perform very well @chimeracoder
#1: Layered interfaces are more flexible than union types #2:
Pay attention to interface contracts #3: Use concurrency to define state machines, and use channels for the input/output #4: Treat errors as values, and ask how they behave #5: Well-architected interfaces perform very well @chimeracoder
Aditya Mukerjee @chimeracoder https://github.com/ChimeraCoder
Further References • “Unpacking Git Packfiles”: https://codewords.recurse.com/issues/three/unpacking-git-packfiles/ • Gitgo: https://github.com/ChimeraCoder/gitgo/
• “Git from the Inside Out”: https://codewords.recurse.com/issues/two/git-from-the-inside-out @chimeracoder
More Decks by Aditya Mukerjee
See All by Aditya Mukerjee
করো: Translating Go to Other (Human) Languages, and Back Again (GopherCon 2020)
chimeracoder
1
130
Building Stripe’s Remote Hub: Scaling Distributed Teams
chimeracoder
1
350
করো: Translating Code to Other (Human) Languages and Back Again
chimeracoder
1
130
করো: Translating Go to Other (Human) Languages, and Back Again (GopherCon Vietnam)
chimeracoder
1
120
Observability from the Panopticon: Measuring What Matters
chimeracoder
2
460
করো: Translating Code to Other (Human) Languages, and Back Again
chimeracoder
1
2.3k
Building Resilient Services in Go
chimeracoder
3
920
Observing Your Go Services
chimeracoder
1
280
You Might Be a Go Contributor Already and Not Know It
chimeracoder
2
480
Featured
See All Featured
Being A Developer After 40
akosma
PRO
92
590k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
Why Our Code Smells
bkeepers
PRO
340
58k
Utilizing Notion as your number one productivity tool
mfonobong
4
640
Automating Front-end Workflow
addyosmani
1370
210k
Become a Pro
speakerdeck
PRO
31
6.4k
Accessibility Awareness
sabderemane
1
300
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
550
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520