SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Go: Beyond the Basics
Joey Gibson
Senior Architect
Lancope, Inc.
@joeygibson
Wednesday, July 31, 13
Agenda
• $GOPATH
• Project Organization
• Packages
• Structs
• Methods
• Interfaces
• Regular Expressions
• Functions are First-Class Citizens
• Goroutines and Channels
Wednesday, July 31, 13
$GOPATH
• A series of directories where Go looks for
sources and libraries
• export GOPATH=~/Projects/gobtb:~/Projects/
gotest
• Must contain a src/ directory, with package
directories under that
• Will contain pkg/ directory after doing an install
• go  env -- shows all variables
Wednesday, July 31, 13
Bash
export GOROOT=/Users/<yourname>/Projects/go
export GOPATH=/opt/go-3rdparty:/Users/
<yourname>/Projects/gotest
export PATH=$GOROOT/bin:$PATH:${GOPATH//://
bin:}/bin
Wednesday, July 31, 13
Project Organization
• Project directory should have a src/ subdirectory
• Files in subdirectories of src/ that are in a package (!main)
install to pkg/$GOOS_$GOARCH
• (e.g. src/foo for a “foo” package)
• go  install  foo will install foo.a in pkg/$GOOS_
$GOARCH
• Files in subdirectories of src/ that are in package main,
install to the bin/ directory (e.g. src/bar for a bar command)
• go  install  bar will install bar executable in bin/
Wednesday, July 31, 13
Packages
• Should live in src/foo, src/bar, etc.
• Everything in the directory will get built into a single “thing” (i.e.
foo.a, bar[.exe])
• Can reference each other; don’t use relative references (e.g.
import  “../bar”)
• Can have subpackages
• package quux -- in src/foo/quux/*.go
• imported as “foo/quux”
• referenced as quux.Q()
• Don’t forget aliases -- import xxx foo/quux
Wednesday, July 31, 13
Structs
• Similar to C structs; data only
• Can have methods associated with them
• Can be created on stack or heap; compiler
decides which based on context
• Can be nested
• ... also anonymously...
Wednesday, July 31, 13
Methods
• Look like functions, but have an extra type
clause that specifies which “thing” the
method is for
• The type clause can take a thing, or a
pointer to a thing
• If specified as *thing, no need to provide
address; Go will handle it
Wednesday, July 31, 13
Interfaces
• Specify required methods a type must provide
• Any named type can implement methods to implement
an interface
• No need to declare that a thing implements an interface
• A thing can implement multiple interfaces
• Like duck typing in Ruby, Python, etc., but...
• A compile-time error will occur if trying to pass a thing
that doesn’t implement a required interface
• Convention is to name with -er suffix: Printer, Looper,
Planner, etc.
Wednesday, July 31, 13
Interfaces:
Semi-Generic
• Declaring that a function takes interface{}
will allow the function to accept anything as
a paramerter
• But that means anything at all
Wednesday, July 31, 13
Regular Expressions
• Full support for Perl regex
• Provides compilation, matching, finding,
splitting, and replacing
• Go’s backquotes allow for things like
`Hwllo` without doubling backslashes
Wednesday, July 31, 13
First-class functions
• Can be
• assigned to variables
• passed as parameters to other functions
• stored in maps, arrays, etc.
• created/executed anonymously
Wednesday, July 31, 13
goroutines
• goroutines execute concurrently, on one or more
threads according to availability
• Very lightweight; start with a 4k stack
• Stack grows and shrinks as necessary
• Run in same address space as calling process...
• Are not parallel by default!
• To parallelize: set GOMAXPROCS > 1
Wednesday, July 31, 13
goroutine rule
• “Do not communicate by sharing memory;
instead, share memory by communicating.”
Wednesday, July 31, 13
Channels
• Datatype providing communication and
synchronization between goroutines
• Channels have a type; only one type of thing can be
pushed over a channel
• Created using make()
• Can be buffered or not (defaults to unbuffered)
• Can be declared read-only or write-only...
• Unbuffered means sends and receives block until both
sides are ready
Wednesday, July 31, 13
Channels
• The <-­‐ operator pushes to, or pulls from, a
channel
• The range operator reads from a channel,
until it’s closed
• Close with close()
Wednesday, July 31, 13
Resources
• Testify: https://github.com/stretchr/testify
• Goclipse: https://code.google.com/p/
goclipse/
Wednesday, July 31, 13

Weitere ähnliche Inhalte

Ähnlich wie Go: Beyond the Basics

Top 20 Drupal Mistakes newbies make
Top 20 Drupal Mistakes newbies makeTop 20 Drupal Mistakes newbies make
Top 20 Drupal Mistakes newbies makeIztok Smolic
 
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...Puppet
 
Balisage - EXPath Packaging
Balisage - EXPath PackagingBalisage - EXPath Packaging
Balisage - EXPath PackagingFlorent Georges
 
Clojure, Web and Luminus
Clojure, Web and LuminusClojure, Web and Luminus
Clojure, Web and LuminusEdward Tsech
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...David Beazley (Dabeaz LLC)
 
Responsive Design and jQuery Mobile
Responsive Design and jQuery MobileResponsive Design and jQuery Mobile
Responsive Design and jQuery MobileTroy Miles
 
Lessons from 4 years of driver develoment
Lessons from 4 years of driver develomentLessons from 4 years of driver develoment
Lessons from 4 years of driver develomentchristkv
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with GoSteven Francia
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of GolangKartik Sura
 
Better Python Coding with Prefect Blocks
Better Python Coding with Prefect BlocksBetter Python Coding with Prefect Blocks
Better Python Coding with Prefect BlocksJeff Hale
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Gruntbenko
 
Cook Up a Runtime with The New OSGi Resolver - Neil Bartlett
Cook Up a Runtime with The New OSGi Resolver - Neil BartlettCook Up a Runtime with The New OSGi Resolver - Neil Bartlett
Cook Up a Runtime with The New OSGi Resolver - Neil Bartlettmfrancis
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Ontology Access Kit_ Workshop Intro Slides.pptx
Ontology Access Kit_ Workshop Intro Slides.pptxOntology Access Kit_ Workshop Intro Slides.pptx
Ontology Access Kit_ Workshop Intro Slides.pptxChris Mungall
 
Yoshiwara-AMATYC2018
Yoshiwara-AMATYC2018Yoshiwara-AMATYC2018
Yoshiwara-AMATYC2018byoshiwara
 

Ähnlich wie Go: Beyond the Basics (20)

Top 20 Drupal Mistakes newbies make
Top 20 Drupal Mistakes newbies makeTop 20 Drupal Mistakes newbies make
Top 20 Drupal Mistakes newbies make
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
Python_book.pdf
Python_book.pdfPython_book.pdf
Python_book.pdf
 
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
 
Balisage - EXPath Packaging
Balisage - EXPath PackagingBalisage - EXPath Packaging
Balisage - EXPath Packaging
 
Clojure, Web and Luminus
Clojure, Web and LuminusClojure, Web and Luminus
Clojure, Web and Luminus
 
Ready to go
Ready to goReady to go
Ready to go
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
 
Responsive Design and jQuery Mobile
Responsive Design and jQuery MobileResponsive Design and jQuery Mobile
Responsive Design and jQuery Mobile
 
Lessons from 4 years of driver develoment
Lessons from 4 years of driver develomentLessons from 4 years of driver develoment
Lessons from 4 years of driver develoment
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of Golang
 
Better Python Coding with Prefect Blocks
Better Python Coding with Prefect BlocksBetter Python Coding with Prefect Blocks
Better Python Coding with Prefect Blocks
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
 
Cook Up a Runtime with The New OSGi Resolver - Neil Bartlett
Cook Up a Runtime with The New OSGi Resolver - Neil BartlettCook Up a Runtime with The New OSGi Resolver - Neil Bartlett
Cook Up a Runtime with The New OSGi Resolver - Neil Bartlett
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Ontology Access Kit_ Workshop Intro Slides.pptx
Ontology Access Kit_ Workshop Intro Slides.pptxOntology Access Kit_ Workshop Intro Slides.pptx
Ontology Access Kit_ Workshop Intro Slides.pptx
 
Yoshiwara-AMATYC2018
Yoshiwara-AMATYC2018Yoshiwara-AMATYC2018
Yoshiwara-AMATYC2018
 

Kürzlich hochgeladen

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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 2024Victor Rentea
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
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 TerraformAndrey Devyatkin
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
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 WoodJuan lago vázquez
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
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
 

Go: Beyond the Basics

  • 1. Go: Beyond the Basics Joey Gibson Senior Architect Lancope, Inc. @joeygibson Wednesday, July 31, 13
  • 2. Agenda • $GOPATH • Project Organization • Packages • Structs • Methods • Interfaces • Regular Expressions • Functions are First-Class Citizens • Goroutines and Channels Wednesday, July 31, 13
  • 3. $GOPATH • A series of directories where Go looks for sources and libraries • export GOPATH=~/Projects/gobtb:~/Projects/ gotest • Must contain a src/ directory, with package directories under that • Will contain pkg/ directory after doing an install • go  env -- shows all variables Wednesday, July 31, 13
  • 5. Project Organization • Project directory should have a src/ subdirectory • Files in subdirectories of src/ that are in a package (!main) install to pkg/$GOOS_$GOARCH • (e.g. src/foo for a “foo” package) • go  install  foo will install foo.a in pkg/$GOOS_ $GOARCH • Files in subdirectories of src/ that are in package main, install to the bin/ directory (e.g. src/bar for a bar command) • go  install  bar will install bar executable in bin/ Wednesday, July 31, 13
  • 6. Packages • Should live in src/foo, src/bar, etc. • Everything in the directory will get built into a single “thing” (i.e. foo.a, bar[.exe]) • Can reference each other; don’t use relative references (e.g. import  “../bar”) • Can have subpackages • package quux -- in src/foo/quux/*.go • imported as “foo/quux” • referenced as quux.Q() • Don’t forget aliases -- import xxx foo/quux Wednesday, July 31, 13
  • 7. Structs • Similar to C structs; data only • Can have methods associated with them • Can be created on stack or heap; compiler decides which based on context • Can be nested • ... also anonymously... Wednesday, July 31, 13
  • 8. Methods • Look like functions, but have an extra type clause that specifies which “thing” the method is for • The type clause can take a thing, or a pointer to a thing • If specified as *thing, no need to provide address; Go will handle it Wednesday, July 31, 13
  • 9. Interfaces • Specify required methods a type must provide • Any named type can implement methods to implement an interface • No need to declare that a thing implements an interface • A thing can implement multiple interfaces • Like duck typing in Ruby, Python, etc., but... • A compile-time error will occur if trying to pass a thing that doesn’t implement a required interface • Convention is to name with -er suffix: Printer, Looper, Planner, etc. Wednesday, July 31, 13
  • 10. Interfaces: Semi-Generic • Declaring that a function takes interface{} will allow the function to accept anything as a paramerter • But that means anything at all Wednesday, July 31, 13
  • 11. Regular Expressions • Full support for Perl regex • Provides compilation, matching, finding, splitting, and replacing • Go’s backquotes allow for things like `Hwllo` without doubling backslashes Wednesday, July 31, 13
  • 12. First-class functions • Can be • assigned to variables • passed as parameters to other functions • stored in maps, arrays, etc. • created/executed anonymously Wednesday, July 31, 13
  • 13. goroutines • goroutines execute concurrently, on one or more threads according to availability • Very lightweight; start with a 4k stack • Stack grows and shrinks as necessary • Run in same address space as calling process... • Are not parallel by default! • To parallelize: set GOMAXPROCS > 1 Wednesday, July 31, 13
  • 14. goroutine rule • “Do not communicate by sharing memory; instead, share memory by communicating.” Wednesday, July 31, 13
  • 15. Channels • Datatype providing communication and synchronization between goroutines • Channels have a type; only one type of thing can be pushed over a channel • Created using make() • Can be buffered or not (defaults to unbuffered) • Can be declared read-only or write-only... • Unbuffered means sends and receives block until both sides are ready Wednesday, July 31, 13
  • 16. Channels • The <-­‐ operator pushes to, or pulls from, a channel • The range operator reads from a channel, until it’s closed • Close with close() Wednesday, July 31, 13
  • 17. Resources • Testify: https://github.com/stretchr/testify • Goclipse: https://code.google.com/p/ goclipse/ Wednesday, July 31, 13