Go Programming Language by Google

Uttam Gandhi
Uttam GandhiSoftware Developer C++, golang, MongoDB en Synerzip
Go	Introduc+on	
U-am	Gandhi
History	of	Go	
•  Robert	Griesemer,	Rob	Pike	and	Ken	
Thompson	started	the	idea	on	Sep	21,	2007	
•  It	became	an	open	source	project	on	Nov	10,	
2009	
•  Go1	was	released	in	March	2012
Why	Go	
•  A	good	mix	of	fast	compila+on,	efficient	
execu+on	and	ease	of	programming	
•  combines	best	of	sta+c	language	and	dynamic	
language	
•  offers	garbage	collec+on,	concurrency,	
scalability	
•  Aims	to	be	system	programming	language	for	
mul+	core	machine
Comparison	with	C++,	Java	and	
Javascript	
C++	 Java	 Javascript	 Go	
Typesafe	 ✔	 ✔	 ✖	 ✔	
Garbage	
Collec+on	
✖	
	
✔	
	
✔	
	
✔	
	
Compila+on	 Slow	 Slow	 NA	 Very	Fast	
Concurrency	 ✖	 ✔	 ✖	 ✔	
Ease	of	
programming	
✖	
	
✔	 ✔	
	
✔	
	
Efficiency	 Highest	 Slow	 Slowest	 Close	to	C++
Hello	World		
// hello.go
package main
import (
    "fmt”
)
func main() {
        fmt.Println("Hello World”)
}
Sample	func+on	
package main
import “fmt”
func split(sum int) (x, y int) {
x = sum * 4 / 9
y = sum - x
return
}
func main() {
var x, y, z int
fmt.Println(x,y,z)
fmt.Println(split(17))
}
How	to	Write	Go	Code	1/2	
•  Go	tool	is	designed	to	work	with	open	source	
code	maintained	in	public	repositories		
•  Workspace	
– src	
– pkg	
– bin		
•  export GOPATH=$HOME/go
•  go install hello
How	to	Write	Go	Code	2/2	
•  go install sum (create and put
lib pkg)
•  go install usinglib
•  go get code.google.com/p/
go.example/hello
•  go test sum
Object	Oriented	Go	
•  No	classes,	no	inheritance	
•  go	has	duck	typing	
•  structs	are	used	for	custom	types,	aggrega+on	
•  Interfaces,	abstract	type	has	methods	
•  Any	custom	type	having	same	methods	as	
interface	follows	that	(and/or	other)	interface	
•  Interface{},	empty	interface	is	like	void	in	C	or	
Object	in	Java
Interface	
type Printer interface {
Print()
}
type MyFloat float64
func (f MyFloat) Print() {
fmt.Println(f);
}
func main() {
var a Printer
f := MyFloat(5.5)
a = f
}
Features				1/2	
•  Garbage	collec+on	
•  Concurrency	
•  Packages	
–  fmt,	net,	os,	+me,	math,	zlib		
–  h-p://golang.org/pkg/	has	the	exhaus+ve	list	
•  Types	
–  bool,	int,	int8,	int16,	int32,	int64,	uint	…,	byte,	float32,float64,	
complex64,	complex128	
–  const	
•  For	loop	only	
•  struct,	access	fields	using	dot	
•  Pointer	but	no	pointer	arithme+c
Features	2/2	
•  Slices	
–  s := []int{2, 3, 5, 7, 11, 13}
–  len(s)
•  Maps		
–  var m map[string]string
–  m[“index”]
•  Func+on	values	
f1 := func(x, y float64) float64 {
return math.Sqrt(x*x + y*y)
}
Concurrency	
•  go	rou+nes		
–  Lightweight	thread	like	rou+ne	(may	be	one	or	more	
thread)	
•  Channels	and	Buffered	Channel	
–  Useful	for	sync	between	go	rou+nes	
–  Send	and	receive	to	channel	is	blocking	(	no	sync	needed)	
•  Range	and	close	
–  Range	used	itera+ng	over	channel	
–  Close	used	by	sender	aier	sending	all	values	
•  Select		
–  Lets	gorou+ne	waits	on	mul+ple	communica+on	
opera+ons
JSON	and	Go	
type Message struct {
Name string
Body string
Time int64
}
m := Message{"Alice", "Hello", 1290090}
b, err := json.Marshal(m)
-----------
b is now
[]byte(`{"Name":"Alice","Body":"Hello","Time
":1290090}`)
Web	Server	
type Hello struct{}
func (h Hello) ServeHTTP(
w http.ResponseWriter,
r *http.Request) {
fmt.Fprint(w, "Hello TechNext !")
}
func main() {
var h Hello
http.ListenAndServe("localhost:4000", h)
}
MongoDB	Driver	(mgo)	
•  Mgo	Driver	can	be	fetched	using	
–  go get gopkg.in/mgo.v2
–  go get gopkg.in/mgo.v2/bson
•  Sample	code	to	connect	to	mongo	
session, err := mgo.Dial("localhost”)
collection :=
session.DB(”mydb").C(”mycollection”)
err := collection.Find(bson.M{”Name”:
“XYZ”}).One(&result)
Go	In	Produc+on	
•  Google	is	using	in	produc+on	for	
–  	h-p://golang.org	
–  Vitess	system	for	large-scale	SQL	installa+ons	
–  Download	server	dl.google.com		
•  It	delivers	chrome	binaries	and	apt-get	packages	
•  Other	companies	using	Go	in	produc+on	
–  InfluxData	
–  Canonical	
–  Heroku	
–  Iron.io	
–  Apcera	
–  Docker	
–  h-p://go-lang.cat-v.org/organiza+ons-using-go
References	
•  FAQ	h-p://golang.org/doc/faq	
•  Installa+on	h-p://golang.org/doc/install	
•  Code		h-p://golang.org/doc/code.html	
•  Videos
h-p://blog.golang.org/go-videos-from-google-
io-2012	
•  Tour	h-p://tour.golang.org/	
•  Efficiency	BM	-	JSON	Benchmarks
References	
•  h-p://www.javaworld.com/ar+cle/2080935/
scrip+ng-jvm-languages/go-google-go-a-
language-on-full-thro-le.html	
•  h-p://blog.golang.org/json-and-go	
•  h-p://www.drdobbs.com/open-source/geong-
going-with-go	
•  h-p://www.drdobbs.com/open-source/why-not-
go/240005062	
•  h-p://www.jellolabs.com/blog/why-golang-is-
ready-for-early-stage-startups.html
References	
•  h-p://stackoverflow.com/ques+ons/11462046/what-
is-the-niche-of-go-lang	
•  h-ps://code.google.com/p/go-wiki/wiki/
SuccessStories#	
•  h-p://stackoverflow.com/ques+ons/12168873/cross-
compile-go-on-osx	
•  h-p://ma-.aimoneo.net/posts/2012/11/27/real-life-
concurrency-in-go/	
•  h-p://www.golang-book.com/10	
•  h-p://ma--welsh.blogspot.in/2013/08/rewri+ng-
large-produc+on-system-in-go.html
1 de 20

Recomendados

Why you should care about Go (Golang) por
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)Aaron Schlesinger
1.6K vistas37 diapositivas
Go. Why it goes por
Go. Why it goesGo. Why it goes
Go. Why it goesSergey Pichkurov
246 vistas69 diapositivas
Go Language presentation por
Go Language presentationGo Language presentation
Go Language presentationGh-Mohammed Eldadah
581 vistas21 diapositivas
Introduction to go lang por
Introduction to go langIntroduction to go lang
Introduction to go langAmal Mohan N
552 vistas40 diapositivas
Go lang por
Go langGo lang
Go langSuelen Carvalho
8.3K vistas35 diapositivas
The Go programming language - Intro by MyLittleAdventure por
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventuremylittleadventure
685 vistas26 diapositivas

Más contenido relacionado

La actualidad más candente

Golang workshop por
Golang workshopGolang workshop
Golang workshopVictor S. Recio
748 vistas41 diapositivas
Linux Systems: Getting started with setting up an Embedded platform por
Linux Systems: Getting started with setting up an Embedded platformLinux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platformEmertxe Information Technologies Pvt Ltd
423 vistas199 diapositivas
Introduction to GoLang por
Introduction to GoLangIntroduction to GoLang
Introduction to GoLangNVISIA
351 vistas48 diapositivas
Linux programming - Getting self started por
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started Emertxe Information Technologies Pvt Ltd
2.5K vistas56 diapositivas
Embedded Linux on ARM por
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARMEmertxe Information Technologies Pvt Ltd
10.5K vistas235 diapositivas
Linux-Internals-and-Networking por
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-NetworkingEmertxe Information Technologies Pvt Ltd
9.1K vistas290 diapositivas

La actualidad más candente(20)

Introduction to GoLang por NVISIA
Introduction to GoLangIntroduction to GoLang
Introduction to GoLang
NVISIA351 vistas
Why do all my ddd apps look the same - Vienna 2014 por Alberto Brandolini
Why do all my ddd apps look the same - Vienna 2014Why do all my ddd apps look the same - Vienna 2014
Why do all my ddd apps look the same - Vienna 2014
Alberto Brandolini3.8K vistas
CI with Gitlab & Docker por Joerg Henning
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
Joerg Henning3.9K vistas
HKG18-217 - OpenCDM/CDMi (Multi DRM) work with WPE & Chromium por Linaro
HKG18-217 - OpenCDM/CDMi (Multi DRM) work with WPE & ChromiumHKG18-217 - OpenCDM/CDMi (Multi DRM) work with WPE & Chromium
HKG18-217 - OpenCDM/CDMi (Multi DRM) work with WPE & Chromium
Linaro1.5K vistas
LAS16-406: Android Widevine on OP-TEE por Linaro
LAS16-406: Android Widevine on OP-TEELAS16-406: Android Widevine on OP-TEE
LAS16-406: Android Widevine on OP-TEE
Linaro1.9K vistas
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G... por GITS Indonesia
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Indonesia516 vistas
Docker introduction por Gourav Varma
Docker introductionDocker introduction
Docker introduction
Gourav Varma242 vistas
Accessing Hardware on Android por Gary Bisson
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
Gary Bisson18.4K vistas

Destacado

Rust - Fernando Borretti por
Rust - Fernando BorrettiRust - Fernando Borretti
Rust - Fernando BorrettiTryolabs
1.1K vistas18 diapositivas
Introduction to Go programming language por
Introduction to Go programming languageIntroduction to Go programming language
Introduction to Go programming languageSlawomir Dorzak
5.7K vistas25 diapositivas
Data Structures In Scala por
Data Structures In ScalaData Structures In Scala
Data Structures In ScalaKnoldus Inc.
11K vistas20 diapositivas
Introduction à Scala - Michel Schinz - January 2010 por
Introduction à Scala - Michel Schinz - January 2010Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010JUG Lausanne
1.4K vistas62 diapositivas
[112] 실전 스위프트 프로그래밍 por
[112] 실전 스위프트 프로그래밍[112] 실전 스위프트 프로그래밍
[112] 실전 스위프트 프로그래밍NAVER D2
13.9K vistas94 diapositivas
[132] rust por
[132] rust[132] rust
[132] rustNAVER D2
12.7K vistas47 diapositivas

Destacado(6)

Rust - Fernando Borretti por Tryolabs
Rust - Fernando BorrettiRust - Fernando Borretti
Rust - Fernando Borretti
Tryolabs 1.1K vistas
Introduction to Go programming language por Slawomir Dorzak
Introduction to Go programming languageIntroduction to Go programming language
Introduction to Go programming language
Slawomir Dorzak5.7K vistas
Data Structures In Scala por Knoldus Inc.
Data Structures In ScalaData Structures In Scala
Data Structures In Scala
Knoldus Inc.11K vistas
Introduction à Scala - Michel Schinz - January 2010 por JUG Lausanne
Introduction à Scala - Michel Schinz - January 2010Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010
JUG Lausanne1.4K vistas
[112] 실전 스위프트 프로그래밍 por NAVER D2
[112] 실전 스위프트 프로그래밍[112] 실전 스위프트 프로그래밍
[112] 실전 스위프트 프로그래밍
NAVER D213.9K vistas
[132] rust por NAVER D2
[132] rust[132] rust
[132] rust
NAVER D212.7K vistas

Similar a Go Programming Language by Google

Golang - Overview of Go (golang) Language por
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
7.1K vistas85 diapositivas
Golang (Go Programming Language) por
Golang (Go Programming Language)Golang (Go Programming Language)
Golang (Go Programming Language)ShubhamMishra485
1.9K vistas15 diapositivas
Golang por
GolangGolang
GolangSaray Chak
43 vistas26 diapositivas
Go Within Cloud Foundry por
Go Within Cloud FoundryGo Within Cloud Foundry
Go Within Cloud FoundryPlatform CF
11.7K vistas43 diapositivas
Intro to Go por
Intro to GoIntro to Go
Intro to GoClarence Bakirtzidis
692 vistas8 diapositivas
GoLang - Why It Matters por
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Mattersrahul
135 vistas60 diapositivas

Similar a Go Programming Language by Google(20)

Golang (Go Programming Language) por ShubhamMishra485
Golang (Go Programming Language)Golang (Go Programming Language)
Golang (Go Programming Language)
ShubhamMishra4851.9K vistas
Go Within Cloud Foundry por Platform CF
Go Within Cloud FoundryGo Within Cloud Foundry
Go Within Cloud Foundry
Platform CF11.7K vistas
GoLang - Why It Matters por rahul
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
rahul 135 vistas
An introduction to go programming language por Technology Parser
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
Technology Parser4K vistas
Happy Go Programming Part 1 por Lin Yo-An
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1
Lin Yo-An5.1K vistas
Go programming language por Appstud
Go programming languageGo programming language
Go programming language
Appstud196 vistas
Back end User Group / Golang Intro por Simone Gentili
Back end User Group / Golang IntroBack end User Group / Golang Intro
Back end User Group / Golang Intro
Simone Gentili206 vistas
Golang for PHP programmers: A practical introduction por Richard Tuin
Golang for PHP programmers: A practical introductionGolang for PHP programmers: A practical introduction
Golang for PHP programmers: A practical introduction
Richard Tuin875 vistas
Google's Go Programming Language - Introduction por Ganesh Samarthyam
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction
Ganesh Samarthyam543 vistas
A First Look at Google's Go Programming Language por Ganesh Samarthyam
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
Ganesh Samarthyam771 vistas
Golang, Future of Programming Language. por Sunil Yadav
Golang, Future of Programming Language.Golang, Future of Programming Language.
Golang, Future of Programming Language.
Sunil Yadav72 vistas
Mender.io | Develop embedded applications faster | Comparing C and Golang por Mender.io
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io677 vistas

Último

Voice Logger - Telephony Integration Solution at Aegis por
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at AegisNirmal Sharma
17 vistas1 diapositiva
SAP Automation Using Bar Code and FIORI.pdf por
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
19 vistas38 diapositivas
handbook for web 3 adoption.pdf por
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdfLiveplex
19 vistas16 diapositivas
Uni Systems for Power Platform.pptx por
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
50 vistas21 diapositivas
Throughput por
ThroughputThroughput
ThroughputMoisés Armani Ramírez
36 vistas11 diapositivas
Spesifikasi Lengkap ASUS Vivobook Go 14 por
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14Dot Semarang
35 vistas1 diapositiva

Último(20)

Voice Logger - Telephony Integration Solution at Aegis por Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 vistas
SAP Automation Using Bar Code and FIORI.pdf por Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Virendra Rai, PMP19 vistas
handbook for web 3 adoption.pdf por Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 vistas
Spesifikasi Lengkap ASUS Vivobook Go 14 por Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 vistas
Black and White Modern Science Presentation.pptx por maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 vistas
The details of description: Techniques, tips, and tangents on alternative tex... por BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 vistas
Java Platform Approach 1.0 - Picnic Meetup por Rick Ossendrijver
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic Meetup
Rick Ossendrijver25 vistas
Empathic Computing: Delivering the Potential of the Metaverse por Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst470 vistas
AMAZON PRODUCT RESEARCH.pdf por JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 vistas
Igniting Next Level Productivity with AI-Infused Data Integration Workflows por Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software225 vistas
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... por NUS-ISS
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
NUS-ISS37 vistas
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum... por NUS-ISS
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
NUS-ISS34 vistas
How the World's Leading Independent Automotive Distributor is Reinventing Its... por NUS-ISS
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...
NUS-ISS15 vistas
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... por NUS-ISS
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
NUS-ISS16 vistas
Report 2030 Digital Decade por Massimo Talia
Report 2030 Digital DecadeReport 2030 Digital Decade
Report 2030 Digital Decade
Massimo Talia14 vistas

Go Programming Language by Google