SlideShare a Scribd company logo
GO PROGRAMMING
GINTO JOSEPH
1325919
COMPUTER SCIENCE DEPT
CHRIST UNIVERSITY
BANGLORE
Go programming introduction
Go programming introduction
AGENDA
* Introduction
* History
* Versions of go
* Key Words
* Operators
* Programs
* Conclusion
* References
• Go is an open source programming language that
makes it easy to build simple, reliable, and
efficient software.
• Go language is for google language
• Developed from c & c++
• General purpose language
• Strongly typed language
• Automatic garbage collection
• Programs constructed from the packages
Introduction
History
• Introduced in 2007
• Language announced in November 2009
• Developed from C and C++ language
• GC compiler is used to compile the program
• BSD(Berkeley Software Distribution) Licensed
Creator of Go programming is Robert Griesemer,
Robe Pike, And Ken Thompson
ROBERT ROBE PICK KEN THOMPSON
Versions of GO
• revisionsgo1 (released 2012/03/28)
• revisionsgo1.1 (released 2013/05/13)Minor
• revisionsgo1.2 (released 2013/12/01)Minor
• revisionsgo1.3 (released 2014/06/18)Minor
• go1.4 (released 2014/12/10)Minor
Key Words of go
• Break , case , chan , const , continue , default ,
defer , else , fallthrough , for , func , go , goto,
if , import , interface , map , package , range ,
return , select , struct , switch , type , var
Operators
Operators combine operands into expressions.
Types of Operators
1. Arithmetic Operators
2. Comparison Operators
3. Integer Overflow
4.Logical Operators
5.Address operators
6.Receive operators
• Arithmetic Operators
Arithmetic operators apply to numeric
values and yield a result of the same type
as the first operand. The four standard
arithmetic operators (+, -, *, /) apply to
integer, floating-point, and complex
types; + also applies to strings. All other
arithmetic operators apply to integers only.
• + sum integers, floats, complex values, strings
• - difference integers, floats, complex values
• * product integers, floats, complex values
• / quotient integers, floats, complex values
• % remainder integers
• & bitwise AND integers
• | bitwise OR integers
• ^ bitwise XOR integers
• &^ bit clear (AND NOT) integers
• << left shift integer
• << unsigned integer
• >> right shift integer
• >> unsigned integer
• Strings can be concatenated using the + operator or
the += assignment operator:
• s := "hi"
• s += " and good bye“
Comparison Operators in go
== equal
!= not equal
< less
<= less or equal
> greater
>= greater or equal
Logical operators in go
&& conditional AND
|| conditional OR
! NOT
Object Oriented GO
No classes , no Inheritance
Go support encapsulation
Comparison between c++, java,
javascript and Go
Go programming introduction
Go programming introduction
Go programming introduction
Go by Example: Hello World
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
Go by Example: Values
Go has various value types including strings, integers,
floats, booleans, etc.
eg: package main
import "fmt"
func main() {
fmt.Println("go" + "lang")
fmt.Println("1+1 =", 1+1)
fmt.Println("7.0/3.0 =", 7.0/3.0)
fmt.Println(true && false)
fmt.Println(true || false)
fmt.Println(!true)
}
go by Example: Variables
package main
import "fmt"
func main() {
var a string = "initial"
fmt.Println(a)
var b, c int = 1, 2
fmt.Println(b, c)
var e int
fmt.Println(e)
}
Go by Example: For
for is Go’s only looping construct. Here are three basic types
of for loops.
package main
import "fmt"
func main() {
i := 1
for i <= 3 {
fmt.Println(i) i = i + 1
}
for j := 7; j <= 9; j++ {
fmt.Println(j)
}
for {
fmt.Println("loop")
break
}
}
Go by Example: If/Else
Branching with if and else in Go is straight-forward.
You can have an if statement without an else.
package main
import "fmt“
func main() {
if 7%2 == 0 {
fmt.Println("7 is even")
} else {
fmt.Println("7 is odd")
}
}
Go by Example: Switch
Switch statements express conditionals across many
branches.
package main
import "fmt“
func main() {
i := 2
switch i {
case 1: fmt.Println("one")
case 2: fmt.Println("two")
case 3: fmt.Println("three")
}
}
Go by Example: Arrays
In Go, an array is a numbered sequence of elements of a specific
length.
package main
import "fmt"
func main() {
var a [5]int
fmt.Println("emp:", a)
b := [5]int{1, 2, 3, 4, 5}
fmt.Println("dcl:", b)
var twoD [2][3]int
for i := 0; i < 2; i++ {
for j := 0; j < 3; j++ {
twoD[i][j] = i + j
}
}
fmt.Println("2d: ", twoD)
}
Go by Example: Slices
A slice is a segment of an array
Arrays slices are indexable and have a length
func main() {
slice1 := []int{1,2,3}
slice2 := append(slice1, 4, 5)
fmt.Println(slice1, slice2)
}
Go by Example: Functions
Functions are central in Go. We’ll learn about functions
with a few different examples. A function is an
independent section of code that maps zero or more
input parameters to zero or more output parameters
package main
import "fmt“
func plus(a int, b int) int {
return a + b
}
func main() {
res := plus(1, 2)
fmt.Println("1+2 =", res)
}
Go by Example: Multiple Return Values
Go has built-in support for multiple return values. This feature
is used often in idiomatic Go, for example to return both
result and error values from a function
package main
import "fmt“
func vals() (int, int) {
return 3, 7
}
func main() {
a, b := vals()
fmt.Println(a)
fmt.Println(b)
_, c := vals()
fmt.Println(c)
}
Go by Example: Pointers
Go supports pointers, allowing you to pass references to values and records
within your program.
package main
import "fmt"
func zeroval(ival int) {
ival = 0
}
func zeroptr(iptr *int) {
*iptr = 0
}
func main() {
i := 1
fmt.Println("initial:", i)
zeroval(i)
fmt.Println("zeroval:", i)
zeroptr(&i)
fmt.Println("zeroptr:", i)
fmt.Println("pointer:", &i)
}
Conclusion
• Go is a fast, Small, easy to learn language
• Actively developed by google
• Tones of third party libraries
• Learn it by using it
REFERENCES
• [1] A. Ashoroft and A. Manna, 'The translation of 'go to' programs
to 'while' programs," in Proc. Int. Fed. Inform. Processing Congr., 1971, vol. 1.
Amsterdam, The Netherlands: North-Holland, 1972.
• [2] S. L. Bloom and C. C. Elgot, "The existence and construction of
free iterative theories," IBM Corp., Yorktown Heights, NY, Res.
Rep. RC-4937, July 1974;also to appear in . Comput. Syst. Sci.
• [3] A. Bohm and A. Jacopini, "Flow diagrams, turing machines and
languages with only two formation rules," Commun. Ass. Comput.
Mach., May 1966.
• [4] A. Bruno and A. Stieglitz, "The expression of algorithms by
charts," J. Ass. Comput. Mach., July 1972.
• [5] C. C. Elgot, 'The common algebraic structure of exit automata
and machines," Comput., Jan. 1971.
Go programming introduction
Go programming introduction
Ad

More Related Content

What's hot (20)

Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F# Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F#
David Alpert
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
go-lang
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
Abdul Haseeb
 
Python advance
Python advancePython advance
Python advance
Deepak Chandella
 
Python Functions 1
Python Functions 1Python Functions 1
Python Functions 1
gsdhindsa
 
Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014
Reuven Lerner
 
Functional Programming in F#
Functional Programming in F#Functional Programming in F#
Functional Programming in F#
Dmitri Nesteruk
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Python basics
Python basicsPython basics
Python basics
Manisha Gholve
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
Abdul Haseeb
 
Python ppt
Python pptPython ppt
Python ppt
Anush verma
 
Reasonable Code With Fsharp
Reasonable Code With FsharpReasonable Code With Fsharp
Reasonable Code With Fsharp
Michael Falanga
 
Python Basics
Python BasicsPython Basics
Python Basics
primeteacher32
 
Python ppt
Python pptPython ppt
Python ppt
Rohit Verma
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
bleis tift
 
Pipeline oriented programming
Pipeline oriented programmingPipeline oriented programming
Pipeline oriented programming
Scott Wlaschin
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
Ishin Vin
 
Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015
Phillip Trelford
 
Go Lang Tutorial
Go Lang TutorialGo Lang Tutorial
Go Lang Tutorial
Wei-Ning Huang
 
Python basics
Python basicsPython basics
Python basics
RANAALIMAJEEDRAJPUT
 
Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F# Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F#
David Alpert
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
go-lang
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
Abdul Haseeb
 
Python Functions 1
Python Functions 1Python Functions 1
Python Functions 1
gsdhindsa
 
Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014
Reuven Lerner
 
Functional Programming in F#
Functional Programming in F#Functional Programming in F#
Functional Programming in F#
Dmitri Nesteruk
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
Abdul Haseeb
 
Reasonable Code With Fsharp
Reasonable Code With FsharpReasonable Code With Fsharp
Reasonable Code With Fsharp
Michael Falanga
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
bleis tift
 
Pipeline oriented programming
Pipeline oriented programmingPipeline oriented programming
Pipeline oriented programming
Scott Wlaschin
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
Ishin Vin
 
Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015
Phillip Trelford
 

Similar to Go programming introduction (20)

Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
Robert Stern
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
Basil N G
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
Mahmoud Masih Tehrani
 
Python programming language presentation
Python programming language presentationPython programming language presentation
Python programming language presentation
dhanishev1
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
Rodolfo Carvalho
 
Golang
GolangGolang
Golang
Felipe Mamud
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
Geeks Anonymes
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
Raveen Perera
 
Golang preso
Golang presoGolang preso
Golang preso
Christopher Foresman
 
Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
Sergey Pichkurov
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
Victor S. Recio
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
Amr Hassan
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
I.I.S. G. Vallauri - Fossano
 
Introduction to Go ProgrammingLanguage.ppt
Introduction to Go ProgrammingLanguage.pptIntroduction to Go ProgrammingLanguage.ppt
Introduction to Go ProgrammingLanguage.ppt
PedroAlexandre215482
 
Golang 101
Golang 101Golang 101
Golang 101
宇 傅
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
Golang 101 (Concurrency vs Parallelism)
Golang 101 (Concurrency vs Parallelism)Golang 101 (Concurrency vs Parallelism)
Golang 101 (Concurrency vs Parallelism)
Pramesti Hatta K.
 
Golang online course
Golang online courseGolang online course
Golang online course
bestonlinecoursescoupon
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
Robert Stern
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
Basil N G
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
Mahmoud Masih Tehrani
 
Python programming language presentation
Python programming language presentationPython programming language presentation
Python programming language presentation
dhanishev1
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
Rodolfo Carvalho
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
Geeks Anonymes
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
Raveen Perera
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
Amr Hassan
 
Introduction to Go ProgrammingLanguage.ppt
Introduction to Go ProgrammingLanguage.pptIntroduction to Go ProgrammingLanguage.ppt
Introduction to Go ProgrammingLanguage.ppt
PedroAlexandre215482
 
Golang 101
Golang 101Golang 101
Golang 101
宇 傅
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
Golang 101 (Concurrency vs Parallelism)
Golang 101 (Concurrency vs Parallelism)Golang 101 (Concurrency vs Parallelism)
Golang 101 (Concurrency vs Parallelism)
Pramesti Hatta K.
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Ad

Recently uploaded (20)

Metallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda PathakMetallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda Pathak
GovindaPathak6
 
Culture Media Microbiology Presentation.pptx
Culture Media Microbiology Presentation.pptxCulture Media Microbiology Presentation.pptx
Culture Media Microbiology Presentation.pptx
mythorlegendbusiness
 
Polymerase Chain Reaction (PCR).Poer Pint
Polymerase Chain Reaction (PCR).Poer PintPolymerase Chain Reaction (PCR).Poer Pint
Polymerase Chain Reaction (PCR).Poer Pint
Dr Showkat Ahmad Wani
 
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
Sérgio Sacani
 
Structure formation with primordial black holes: collisional dynamics, binari...
Structure formation with primordial black holes: collisional dynamics, binari...Structure formation with primordial black holes: collisional dynamics, binari...
Structure formation with primordial black holes: collisional dynamics, binari...
Sérgio Sacani
 
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
abayamargaug
 
Zoonosis, Types, Causes. A comprehensive pptx
Zoonosis, Types, Causes. A comprehensive pptxZoonosis, Types, Causes. A comprehensive pptx
Zoonosis, Types, Causes. A comprehensive pptx
Dr Showkat Ahmad Wani
 
06-Molecular basis of transformation.pptx
06-Molecular basis of transformation.pptx06-Molecular basis of transformation.pptx
06-Molecular basis of transformation.pptx
LanaQadumii
 
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Gender Bias and Empathy in Robots:  Insights into Robotic Service FailuresGender Bias and Empathy in Robots:  Insights into Robotic Service Failures
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Selcen Ozturkcan
 
Skmuscle_properties_muscletone_muscletype.pptx
Skmuscle_properties_muscletone_muscletype.pptxSkmuscle_properties_muscletone_muscletype.pptx
Skmuscle_properties_muscletone_muscletype.pptx
muralinath2
 
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,PhosphorosClass-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
govindapathak8
 
Concise Notes on tree and graph data structure
Concise Notes on tree and graph data structureConcise Notes on tree and graph data structure
Concise Notes on tree and graph data structure
YekoyeTigabu2
 
Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...
Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...
Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...
ss0077014
 
APES 6.5 Presentation Fossil Fuels .pdf
APES 6.5 Presentation Fossil Fuels   .pdfAPES 6.5 Presentation Fossil Fuels   .pdf
APES 6.5 Presentation Fossil Fuels .pdf
patelereftu
 
Presentatation_SM_muscle_structpes_funtionre_ty.pptx
Presentatation_SM_muscle_structpes_funtionre_ty.pptxPresentatation_SM_muscle_structpes_funtionre_ty.pptx
Presentatation_SM_muscle_structpes_funtionre_ty.pptx
muralinath2
 
Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...
Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...
Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...
Ali Raei
 
amino compounds.pptx class 12_Govinda Pathak
amino compounds.pptx class 12_Govinda Pathakamino compounds.pptx class 12_Govinda Pathak
amino compounds.pptx class 12_Govinda Pathak
GovindaPathak6
 
Hardy_Weinbergs_law_and[1]. A simple Explanation
Hardy_Weinbergs_law_and[1]. A simple ExplanationHardy_Weinbergs_law_and[1]. A simple Explanation
Hardy_Weinbergs_law_and[1]. A simple Explanation
Dr Showkat Ahmad Wani
 
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Yasasi Abeysinghe
 
Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...
Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...
Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...
muralinath2
 
Metallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda PathakMetallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda Pathak
GovindaPathak6
 
Culture Media Microbiology Presentation.pptx
Culture Media Microbiology Presentation.pptxCulture Media Microbiology Presentation.pptx
Culture Media Microbiology Presentation.pptx
mythorlegendbusiness
 
Polymerase Chain Reaction (PCR).Poer Pint
Polymerase Chain Reaction (PCR).Poer PintPolymerase Chain Reaction (PCR).Poer Pint
Polymerase Chain Reaction (PCR).Poer Pint
Dr Showkat Ahmad Wani
 
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
Sérgio Sacani
 
Structure formation with primordial black holes: collisional dynamics, binari...
Structure formation with primordial black holes: collisional dynamics, binari...Structure formation with primordial black holes: collisional dynamics, binari...
Structure formation with primordial black holes: collisional dynamics, binari...
Sérgio Sacani
 
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
abayamargaug
 
Zoonosis, Types, Causes. A comprehensive pptx
Zoonosis, Types, Causes. A comprehensive pptxZoonosis, Types, Causes. A comprehensive pptx
Zoonosis, Types, Causes. A comprehensive pptx
Dr Showkat Ahmad Wani
 
06-Molecular basis of transformation.pptx
06-Molecular basis of transformation.pptx06-Molecular basis of transformation.pptx
06-Molecular basis of transformation.pptx
LanaQadumii
 
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Gender Bias and Empathy in Robots:  Insights into Robotic Service FailuresGender Bias and Empathy in Robots:  Insights into Robotic Service Failures
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Selcen Ozturkcan
 
Skmuscle_properties_muscletone_muscletype.pptx
Skmuscle_properties_muscletone_muscletype.pptxSkmuscle_properties_muscletone_muscletype.pptx
Skmuscle_properties_muscletone_muscletype.pptx
muralinath2
 
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,PhosphorosClass-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
govindapathak8
 
Concise Notes on tree and graph data structure
Concise Notes on tree and graph data structureConcise Notes on tree and graph data structure
Concise Notes on tree and graph data structure
YekoyeTigabu2
 
Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...
Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...
Water analysis practical for ph, tds, hardness, acidity, conductivity, and ba...
ss0077014
 
APES 6.5 Presentation Fossil Fuels .pdf
APES 6.5 Presentation Fossil Fuels   .pdfAPES 6.5 Presentation Fossil Fuels   .pdf
APES 6.5 Presentation Fossil Fuels .pdf
patelereftu
 
Presentatation_SM_muscle_structpes_funtionre_ty.pptx
Presentatation_SM_muscle_structpes_funtionre_ty.pptxPresentatation_SM_muscle_structpes_funtionre_ty.pptx
Presentatation_SM_muscle_structpes_funtionre_ty.pptx
muralinath2
 
Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...
Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...
Turkey Diseases and Disorders Volume 2 Infectious and Nutritional Diseases, D...
Ali Raei
 
amino compounds.pptx class 12_Govinda Pathak
amino compounds.pptx class 12_Govinda Pathakamino compounds.pptx class 12_Govinda Pathak
amino compounds.pptx class 12_Govinda Pathak
GovindaPathak6
 
Hardy_Weinbergs_law_and[1]. A simple Explanation
Hardy_Weinbergs_law_and[1]. A simple ExplanationHardy_Weinbergs_law_and[1]. A simple Explanation
Hardy_Weinbergs_law_and[1]. A simple Explanation
Dr Showkat Ahmad Wani
 
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Yasasi Abeysinghe
 
Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...
Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...
Body temperature_chemical thermogenesis_hypothermia_hypothermiaMetabolic acti...
muralinath2
 
Ad

Go programming introduction

  • 1. GO PROGRAMMING GINTO JOSEPH 1325919 COMPUTER SCIENCE DEPT CHRIST UNIVERSITY BANGLORE
  • 4. AGENDA * Introduction * History * Versions of go * Key Words * Operators * Programs * Conclusion * References
  • 5. • Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. • Go language is for google language • Developed from c & c++ • General purpose language • Strongly typed language • Automatic garbage collection • Programs constructed from the packages Introduction
  • 6. History • Introduced in 2007 • Language announced in November 2009 • Developed from C and C++ language • GC compiler is used to compile the program • BSD(Berkeley Software Distribution) Licensed
  • 7. Creator of Go programming is Robert Griesemer, Robe Pike, And Ken Thompson ROBERT ROBE PICK KEN THOMPSON
  • 8. Versions of GO • revisionsgo1 (released 2012/03/28) • revisionsgo1.1 (released 2013/05/13)Minor • revisionsgo1.2 (released 2013/12/01)Minor • revisionsgo1.3 (released 2014/06/18)Minor • go1.4 (released 2014/12/10)Minor
  • 9. Key Words of go • Break , case , chan , const , continue , default , defer , else , fallthrough , for , func , go , goto, if , import , interface , map , package , range , return , select , struct , switch , type , var
  • 10. Operators Operators combine operands into expressions. Types of Operators 1. Arithmetic Operators 2. Comparison Operators 3. Integer Overflow 4.Logical Operators 5.Address operators 6.Receive operators
  • 11. • Arithmetic Operators Arithmetic operators apply to numeric values and yield a result of the same type as the first operand. The four standard arithmetic operators (+, -, *, /) apply to integer, floating-point, and complex types; + also applies to strings. All other arithmetic operators apply to integers only.
  • 12. • + sum integers, floats, complex values, strings • - difference integers, floats, complex values • * product integers, floats, complex values • / quotient integers, floats, complex values • % remainder integers • & bitwise AND integers • | bitwise OR integers • ^ bitwise XOR integers • &^ bit clear (AND NOT) integers • << left shift integer • << unsigned integer • >> right shift integer • >> unsigned integer
  • 13. • Strings can be concatenated using the + operator or the += assignment operator: • s := "hi" • s += " and good bye“
  • 14. Comparison Operators in go == equal != not equal < less <= less or equal > greater >= greater or equal Logical operators in go && conditional AND || conditional OR ! NOT
  • 15. Object Oriented GO No classes , no Inheritance Go support encapsulation
  • 16. Comparison between c++, java, javascript and Go
  • 20. Go by Example: Hello World package main import "fmt" func main() { fmt.Println("hello world") }
  • 21. Go by Example: Values Go has various value types including strings, integers, floats, booleans, etc. eg: package main import "fmt" func main() { fmt.Println("go" + "lang") fmt.Println("1+1 =", 1+1) fmt.Println("7.0/3.0 =", 7.0/3.0) fmt.Println(true && false) fmt.Println(true || false) fmt.Println(!true) }
  • 22. go by Example: Variables package main import "fmt" func main() { var a string = "initial" fmt.Println(a) var b, c int = 1, 2 fmt.Println(b, c) var e int fmt.Println(e) }
  • 23. Go by Example: For for is Go’s only looping construct. Here are three basic types of for loops. package main import "fmt" func main() { i := 1 for i <= 3 { fmt.Println(i) i = i + 1 } for j := 7; j <= 9; j++ { fmt.Println(j) } for { fmt.Println("loop") break } }
  • 24. Go by Example: If/Else Branching with if and else in Go is straight-forward. You can have an if statement without an else. package main import "fmt“ func main() { if 7%2 == 0 { fmt.Println("7 is even") } else { fmt.Println("7 is odd") } }
  • 25. Go by Example: Switch Switch statements express conditionals across many branches. package main import "fmt“ func main() { i := 2 switch i { case 1: fmt.Println("one") case 2: fmt.Println("two") case 3: fmt.Println("three") } }
  • 26. Go by Example: Arrays In Go, an array is a numbered sequence of elements of a specific length. package main import "fmt" func main() { var a [5]int fmt.Println("emp:", a) b := [5]int{1, 2, 3, 4, 5} fmt.Println("dcl:", b) var twoD [2][3]int for i := 0; i < 2; i++ { for j := 0; j < 3; j++ { twoD[i][j] = i + j } } fmt.Println("2d: ", twoD) }
  • 27. Go by Example: Slices A slice is a segment of an array Arrays slices are indexable and have a length func main() { slice1 := []int{1,2,3} slice2 := append(slice1, 4, 5) fmt.Println(slice1, slice2) }
  • 28. Go by Example: Functions Functions are central in Go. We’ll learn about functions with a few different examples. A function is an independent section of code that maps zero or more input parameters to zero or more output parameters package main import "fmt“ func plus(a int, b int) int { return a + b } func main() { res := plus(1, 2) fmt.Println("1+2 =", res) }
  • 29. Go by Example: Multiple Return Values Go has built-in support for multiple return values. This feature is used often in idiomatic Go, for example to return both result and error values from a function package main import "fmt“ func vals() (int, int) { return 3, 7 } func main() { a, b := vals() fmt.Println(a) fmt.Println(b) _, c := vals() fmt.Println(c) }
  • 30. Go by Example: Pointers Go supports pointers, allowing you to pass references to values and records within your program. package main import "fmt" func zeroval(ival int) { ival = 0 } func zeroptr(iptr *int) { *iptr = 0 } func main() { i := 1 fmt.Println("initial:", i) zeroval(i) fmt.Println("zeroval:", i) zeroptr(&i) fmt.Println("zeroptr:", i) fmt.Println("pointer:", &i) }
  • 31. Conclusion • Go is a fast, Small, easy to learn language • Actively developed by google • Tones of third party libraries • Learn it by using it
  • 32. REFERENCES • [1] A. Ashoroft and A. Manna, 'The translation of 'go to' programs to 'while' programs," in Proc. Int. Fed. Inform. Processing Congr., 1971, vol. 1. Amsterdam, The Netherlands: North-Holland, 1972. • [2] S. L. Bloom and C. C. Elgot, "The existence and construction of free iterative theories," IBM Corp., Yorktown Heights, NY, Res. Rep. RC-4937, July 1974;also to appear in . Comput. Syst. Sci. • [3] A. Bohm and A. Jacopini, "Flow diagrams, turing machines and languages with only two formation rules," Commun. Ass. Comput. Mach., May 1966. • [4] A. Bruno and A. Stieglitz, "The expression of algorithms by charts," J. Ass. Comput. Mach., July 1972. • [5] C. C. Elgot, 'The common algebraic structure of exit automata and machines," Comput., Jan. 1971.