Implementing acommand line client toGitHub in GoOwen Ou@JingwenOwenOu
Agenda• Automating Git/GitHub workflows with gh• Introduction to Go• What I learnt from implementing gh withGo
What’s gh?• a command line tool that makes workingwith GitHub easier• gh pull• gh ci• gh fork• etc.
A broken workflow• git checkout -b new_feature• some code changes...• git add .• git commit -m “A comment”• git push origin...
An optimized workflow• git checkout -b new_feature• some code changes...• git add .• git commit -m “A comment”• git push or...
Demo
Implementation of gh• Implemented in Go• Fast (40% faster than Hub)• A single, statically linked binary with nodependencie...
What’s Go?• Imperative• Object-oriented like• Concurrent• Compile to machine code• Created at 2009, v1.1.1
Ken Thompson• Founding father of Unix, see“Coders at work”• Bring in regular expressionto computing• Created grep in an ev...
Robert Griesemer• Native code generation forV8• Java HotSpotVM• StrongtalkVM (inspires theDartVM)
Rob Pike• First window system forUnix at Bell Labs• Plan 9• Co-Authors of “The UnixProgramming Environment”& “The Practice...
Why Go?• Why Learn Go? An interview with RobPike: http://www.youtube.com/watch?v=FTl0tl9BGdc
Hello Go
More about Go• Compilation is very fast, gh has 1581 LOC,the build time is 0.77s• Static typing & type inference• Low leve...
Interfaces
The C10K Problem• The problem of optimizing socket serversoftware to handle a large number ofclients at the same time• C10...
Goroutines• Coroutines in Go, 4K, light weight threads• Segmented stacks (a double linked lists)• No stack-overflow• Automa...
Goroutines
Channels
Learning from gh• Right tool for the job - building a Unix tool• Go’s compiler is freaking fast!• Clarity and simplicity, ...
References• gh: https://github.com/jingweno/gh• Code examples: https://gist.github.com/jingweno/c00e973ade6d66b827fd• Go a...
Q&A
Upcoming SlideShare
Loading in …5
×

Implementing a command line client to GitHub in Go

388 views
288 views

Published on

My experience of building gh (https://github.com/jingweno/gh) in Go

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
388
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Implementing a command line client to GitHub in Go

  1. 1. Implementing acommand line client toGitHub in GoOwen Ou@JingwenOwenOu
  2. 2. Agenda• Automating Git/GitHub workflows with gh• Introduction to Go• What I learnt from implementing gh withGo
  3. 3. What’s gh?• a command line tool that makes workingwith GitHub easier• gh pull• gh ci• gh fork• etc.
  4. 4. A broken workflow• git checkout -b new_feature• some code changes...• git add .• git commit -m “A comment”• git push origin HEAD• check CI status, oops..context switch• create a pull request, oops...context switch
  5. 5. An optimized workflow• git checkout -b new_feature• some code changes...• git add .• git commit -m “A comment”• git push origin HEAD• gh ci # prints build status• gh pull # creates a pull request
  6. 6. Demo
  7. 7. Implementation of gh• Implemented in Go• Fast (40% faster than Hub)• A single, statically linked binary with nodependencies (noVM needed!)• Unix, e.g., gh pull -b integration -hnew_feature
  8. 8. What’s Go?• Imperative• Object-oriented like• Concurrent• Compile to machine code• Created at 2009, v1.1.1
  9. 9. Ken Thompson• Founding father of Unix, see“Coders at work”• Bring in regular expressionto computing• Created grep in an evening• Designed UTF-8 on a dinerplacemat
  10. 10. Robert Griesemer• Native code generation forV8• Java HotSpotVM• StrongtalkVM (inspires theDartVM)
  11. 11. Rob Pike• First window system forUnix at Bell Labs• Plan 9• Co-Authors of “The UnixProgramming Environment”& “The Practice ofProgramming” with BrianKernighan• Newsqueak, Limbo:implementations of TonyHoare’s CSP
  12. 12. Why Go?• Why Learn Go? An interview with RobPike: http://www.youtube.com/watch?v=FTl0tl9BGdc
  13. 13. Hello Go
  14. 14. More about Go• Compilation is very fast, gh has 1581 LOC,the build time is 0.77s• Static typing & type inference• Low level primitives uint, float64• Garbage collected• Pointers without pointer arithmetic
  15. 15. Interfaces
  16. 16. The C10K Problem• The problem of optimizing socket serversoftware to handle a large number ofclients at the same time• C10k = concurrent ten thousandconnections• Linux pthreads (8MB),Windows (1MB),Coroutines (4k, e.g., Ruby Fibers)
  17. 17. Goroutines• Coroutines in Go, 4K, light weight threads• Segmented stacks (a double linked lists)• No stack-overflow• Automatically scale to multiple-cores• In the future, scale to multiple machines
  18. 18. Goroutines
  19. 19. Channels
  20. 20. Learning from gh• Right tool for the job - building a Unix tool• Go’s compiler is freaking fast!• Clarity and simplicity, less is more• Go fmt• Fast startup time, low memory usage• Deploy a static library (making deployment somuch simpler!)• Goroutines & channels (higher level APIs in net/http)
  21. 21. References• gh: https://github.com/jingweno/gh• Code examples: https://gist.github.com/jingweno/c00e973ade6d66b827fd• Go at Google: http://www.infoq.com/presentations/Go-Google• Concurrency is not Parallelism: http://vimeo.com/49718712• Real world Go: https://gist.github.com/ungerik/3731476
  22. 22. Q&A

×