SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Implementing a
command line client to
GitHub in Go
Owen Ou
@JingwenOwenOu
Agenda
• Automating Git/GitHub workflows with gh
• Introduction to Go
• What I learnt from implementing gh with
Go
What’s gh?
• a command line tool that makes working
with 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 HEAD
• check CI status, oops..context switch
• create a pull request, oops...context switch
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
Demo
Implementation of gh
• Implemented in Go
• Fast (40% faster than Hub)
• A single, statically linked binary with no
dependencies (noVM needed!)
• Unix, e.g., gh pull -b integration -h
new_feature
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 expression
to computing
• Created grep in an evening
• Designed UTF-8 on a diner
placemat
Robert Griesemer
• Native code generation for
V8
• Java HotSpotVM
• StrongtalkVM (inspires the
DartVM)
Rob Pike
• First window system for
Unix at Bell Labs
• Plan 9
• Co-Authors of “The Unix
Programming Environment”
& “The Practice of
Programming” with Brian
Kernighan
• Newsqueak, Limbo:
implementations of Tony
Hoare’s CSP
Why Go?
• Why Learn Go? An interview with Rob
Pike: 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 level primitives uint, float64
• Garbage collected
• Pointers without pointer arithmetic
Interfaces
The C10K Problem
• The problem of optimizing socket server
software to handle a large number of
clients at the same time
• C10k = concurrent ten thousand
connections
• Linux pthreads (8MB),Windows (1MB),
Coroutines (4k, e.g., Ruby Fibers)
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
Goroutines
Channels
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 so
much simpler!)
• Goroutines & channels (higher level APIs in net/
http)
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
Q&A

Mais conteúdo relacionado

Mais procurados

Developing Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScriptDeveloping Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScript
nohuhu
 

Mais procurados (20)

Apache Airflow
Apache AirflowApache Airflow
Apache Airflow
 
Infrastructure as "Code" with Pulumi
Infrastructure as "Code" with PulumiInfrastructure as "Code" with Pulumi
Infrastructure as "Code" with Pulumi
 
Developing Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScriptDeveloping Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScript
 
Celery
CeleryCelery
Celery
 
Continuous deployment of Rails apps on AWS OpsWorks
Continuous deployment of Rails apps on AWS OpsWorksContinuous deployment of Rails apps on AWS OpsWorks
Continuous deployment of Rails apps on AWS OpsWorks
 
Infrastructure-as-Code with Pulumi - Better than all the others (like Ansible)?
Infrastructure-as-Code with Pulumi- Better than all the others (like Ansible)?Infrastructure-as-Code with Pulumi- Better than all the others (like Ansible)?
Infrastructure-as-Code with Pulumi - Better than all the others (like Ansible)?
 
Plone migrations using plone.restapi
Plone migrations using plone.restapiPlone migrations using plone.restapi
Plone migrations using plone.restapi
 
Plone 5.2 migration at University Ghent, Belgium
Plone 5.2 migration at University Ghent, BelgiumPlone 5.2 migration at University Ghent, Belgium
Plone 5.2 migration at University Ghent, Belgium
 
PR workflow
PR workflowPR workflow
PR workflow
 
Git
GitGit
Git
 
So you want to write a cloud function
So you want to write a cloud functionSo you want to write a cloud function
So you want to write a cloud function
 
.Net Core 3.0. What’s inside? Павло Голубович
.Net Core 3.0. What’s inside? Павло Голубович.Net Core 3.0. What’s inside? Павло Голубович
.Net Core 3.0. What’s inside? Павло Голубович
 
Asynchronous job queues with python-rq
Asynchronous job queues with python-rqAsynchronous job queues with python-rq
Asynchronous job queues with python-rq
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
 
Amsterdam Meetup Presentation - Marts 2014
Amsterdam Meetup Presentation - Marts 2014Amsterdam Meetup Presentation - Marts 2014
Amsterdam Meetup Presentation - Marts 2014
 
Part 3 of the REAL Webinars on Oracle Cloud Native Application Development (J...
Part 3 of the REAL Webinars on Oracle Cloud Native Application Development (J...Part 3 of the REAL Webinars on Oracle Cloud Native Application Development (J...
Part 3 of the REAL Webinars on Oracle Cloud Native Application Development (J...
 
Pre-rendering single page app
Pre-rendering single page appPre-rendering single page app
Pre-rendering single page app
 
Apache Airflow Introduction
Apache Airflow IntroductionApache Airflow Introduction
Apache Airflow Introduction
 
Scaling application servers for efficiency
Scaling application servers for efficiencyScaling application servers for efficiency
Scaling application servers for efficiency
 
Celery workshop
Celery workshopCelery workshop
Celery workshop
 

Destaque (6)

Doing More with Less: Mash Your Way to Productivity
Doing More with Less: Mash Your Way to ProductivityDoing More with Less: Mash Your Way to Productivity
Doing More with Less: Mash Your Way to Productivity
 
Dspace at CUNY
Dspace at CUNYDspace at CUNY
Dspace at CUNY
 
Improving DSpace Backups, Restores & Migrations
Improving DSpace Backups, Restores & MigrationsImproving DSpace Backups, Restores & Migrations
Improving DSpace Backups, Restores & Migrations
 
Dspace software
Dspace softwareDspace software
Dspace software
 
Making DSpace XMLUI Your Own
Making DSpace XMLUI Your OwnMaking DSpace XMLUI Your Own
Making DSpace XMLUI Your Own
 
DSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & Configuration
 

Semelhante a Implementing a command line client to GitHub in Go

Python to go
Python to goPython to go
Python to go
Weng Wei
 
Progressive Enhancement using WSGI
Progressive Enhancement using WSGIProgressive Enhancement using WSGI
Progressive Enhancement using WSGI
Matthew Wilkes
 
Untangling fall2017 week2_try2
Untangling fall2017 week2_try2Untangling fall2017 week2_try2
Untangling fall2017 week2_try2
Derek Jacoby
 

Semelhante a Implementing a command line client to GitHub in Go (20)

Python to go
Python to goPython to go
Python to go
 
Jenkins-Koji plugin presentation on Python & Ruby devel group @ Brno
Jenkins-Koji plugin presentation on Python & Ruby devel group @ BrnoJenkins-Koji plugin presentation on Python & Ruby devel group @ Brno
Jenkins-Koji plugin presentation on Python & Ruby devel group @ Brno
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
 
Introduction to Git for Network Engineers
Introduction to Git for Network EngineersIntroduction to Git for Network Engineers
Introduction to Git for Network Engineers
 
Infrastructure, Hiphop for PHP, deploy @ Hyves
Infrastructure, Hiphop for PHP, deploy @ HyvesInfrastructure, Hiphop for PHP, deploy @ Hyves
Infrastructure, Hiphop for PHP, deploy @ Hyves
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Go: What's Different ?
Go: What's Different ?Go: What's Different ?
Go: What's Different ?
 
State of NuPIC
State of NuPICState of NuPIC
State of NuPIC
 
Progressive Enhancement using WSGI
Progressive Enhancement using WSGIProgressive Enhancement using WSGI
Progressive Enhancement using WSGI
 
cadec-2017-golang
cadec-2017-golangcadec-2017-golang
cadec-2017-golang
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
PySide
PySidePySide
PySide
 
orlando-codecamp-meet-copilot-24-Feb-2024_pub.pptx
orlando-codecamp-meet-copilot-24-Feb-2024_pub.pptxorlando-codecamp-meet-copilot-24-Feb-2024_pub.pptx
orlando-codecamp-meet-copilot-24-Feb-2024_pub.pptx
 
Why my Go program is slow?
Why my Go program is slow?Why my Go program is slow?
Why my Go program is slow?
 
Fission Introduction
Fission IntroductionFission Introduction
Fission Introduction
 
Untangling fall2017 week2
Untangling fall2017 week2Untangling fall2017 week2
Untangling fall2017 week2
 
Untangling fall2017 week2_try2
Untangling fall2017 week2_try2Untangling fall2017 week2_try2
Untangling fall2017 week2_try2
 
C og c++-jens lund jensen
C og c++-jens lund jensenC og c++-jens lund jensen
C og c++-jens lund jensen
 
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared LibraryCodifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Implementing a command line client to GitHub in Go

  • 1. Implementing a command line client to GitHub in Go Owen Ou @JingwenOwenOu
  • 2. Agenda • Automating Git/GitHub workflows with gh • Introduction to Go • What I learnt from implementing gh with Go
  • 3. What’s gh? • a command line tool that makes working with GitHub easier • gh pull • gh ci • gh fork • etc.
  • 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. 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
  • 7. Implementation of gh • Implemented in Go • Fast (40% faster than Hub) • A single, statically linked binary with no dependencies (noVM needed!) • Unix, e.g., gh pull -b integration -h new_feature
  • 8. What’s Go? • Imperative • Object-oriented like • Concurrent • Compile to machine code • Created at 2009, v1.1.1
  • 9. Ken Thompson • Founding father of Unix, see “Coders at work” • Bring in regular expression to computing • Created grep in an evening • Designed UTF-8 on a diner placemat
  • 10. Robert Griesemer • Native code generation for V8 • Java HotSpotVM • StrongtalkVM (inspires the DartVM)
  • 11. Rob Pike • First window system for Unix at Bell Labs • Plan 9 • Co-Authors of “The Unix Programming Environment” & “The Practice of Programming” with Brian Kernighan • Newsqueak, Limbo: implementations of Tony Hoare’s CSP
  • 12. Why Go? • Why Learn Go? An interview with Rob Pike: http://www.youtube.com/watch? v=FTl0tl9BGdc
  • 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
  • 16. The C10K Problem • The problem of optimizing socket server software to handle a large number of clients at the same time • C10k = concurrent ten thousand connections • Linux pthreads (8MB),Windows (1MB), Coroutines (4k, e.g., Ruby Fibers)
  • 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
  • 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 so much simpler!) • Goroutines & channels (higher level APIs in net/ http)
  • 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. Q&A