SlideShare a Scribd company logo
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

More Related Content

PPTX
Introduction to go lang
PPTX
Go Programming language, golang
PPTX
Golang (Go Programming Language)
PDF
PDF
The Go programming language - Intro by MyLittleAdventure
PPTX
Go. Why it goes
PPTX
Go Programming Language (Golang)
PDF
Go language presentation
Introduction to go lang
Go Programming language, golang
Golang (Go Programming Language)
The Go programming language - Intro by MyLittleAdventure
Go. Why it goes
Go Programming Language (Golang)
Go language presentation

What's hot (20)

PPT
GO programming language
PDF
Golang 101
PPTX
Go Language presentation
PDF
Golang
PPTX
Golang - Overview of Go (golang) Language
PDF
GoLang Introduction
PDF
Conan a C/C++ Package Manager
PDF
Coding with golang
PDF
Git 101: Git and GitHub for Beginners
PDF
Go Lang Tutorial
PDF
Introduction to go language programming
PDF
Introduction to Go programming language
PDF
Golang and Eco-System Introduction / Overview
PPTX
Introduction to GoLang
PPSX
Golang getting started
PPT
The Kotlin Programming Language
PPTX
Google colab introduction
PPTX
MongoDB + Java + Spring Data
PDF
gRPC Overview
GO programming language
Golang 101
Go Language presentation
Golang
Golang - Overview of Go (golang) Language
GoLang Introduction
Conan a C/C++ Package Manager
Coding with golang
Git 101: Git and GitHub for Beginners
Go Lang Tutorial
Introduction to go language programming
Introduction to Go programming language
Golang and Eco-System Introduction / Overview
Introduction to GoLang
Golang getting started
The Kotlin Programming Language
Google colab introduction
MongoDB + Java + Spring Data
gRPC Overview
Ad

Similar to Go Programming Language by Google (20)

PDF
Introduction to go, and why it's awesome
PDF
Golang
PDF
Inroduction to golang
PPT
Introduction to Go ProgrammingLanguage.ppt
PDF
A gentle intro to Golang and the Go-universe
PPTX
Go fundamentals
PDF
Introduction to Go
PDF
Getting started with Go at GDays Nigeria 2014
PDF
An Introduction to Go
PDF
A quick introduction to go
PDF
Introduction to Programming in Go
PDF
Happy Go programing
PDF
Welcome to Go
ODP
Ready to go
PPTX
Golang introduction
PDF
Go introduction
PPTX
Go programming introduction
PDF
Coding in GO - GDG SL - NSBM
PPT
A First Look at Google's Go Programming Language
PPT
Google's Go Programming Language - Introduction
Introduction to go, and why it's awesome
Golang
Inroduction to golang
Introduction to Go ProgrammingLanguage.ppt
A gentle intro to Golang and the Go-universe
Go fundamentals
Introduction to Go
Getting started with Go at GDays Nigeria 2014
An Introduction to Go
A quick introduction to go
Introduction to Programming in Go
Happy Go programing
Welcome to Go
Ready to go
Golang introduction
Go introduction
Go programming introduction
Coding in GO - GDG SL - NSBM
A First Look at Google's Go Programming Language
Google's Go Programming Language - Introduction
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Encapsulation theory and applications.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPT
Teaching material agriculture food technology
PDF
Getting Started with Data Integration: FME Form 101
PDF
August Patch Tuesday
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Group 1 Presentation -Planning and Decision Making .pptx
OMC Textile Division Presentation 2021.pptx
Encapsulation_ Review paper, used for researhc scholars
Encapsulation theory and applications.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Teaching material agriculture food technology
Getting Started with Data Integration: FME Form 101
August Patch Tuesday
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Heart disease approach using modified random forest and particle swarm optimi...
Accuracy of neural networks in brain wave diagnosis of schizophrenia

Go Programming Language by Google