Upgrade to Pro — share decks privately, control downloads, hide ads and more …

cloning_git_in_go_gophercon_india.pdf

Aditya Mukerjee
February 25, 2017
29

 cloning_git_in_go_gophercon_india.pdf

Aditya Mukerjee

February 25, 2017
Tweet

More Decks by Aditya Mukerjee

Transcript

  1. 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
  2. Bootstrapping Git in Go “We can just use the real

    .git directory for our tests, right?” @chimeracoder …nope.
  3. 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> + “!”
  4. @chimeracoder type Reader interface { Read(p []byte) (n int, err

    error) } Object 1 Object 2 Object 3 Object 4 …
  5. • Discovery #3: Use concurrency to define state machines, and

    use channels for the input/output @chimeracoder f1 f3 f2 g g1 if f g2
  6. • Discovery #4: Treat errors as values, and ask how

    they behave @chimeracoder httpdir.Open() ParsePackfile() GitFetch()
  7. #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
  8. 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