SlideShare a Scribd company logo
The Go Programming Language
Seminar Guide:
Ms. Alby S.
Assistant Professor
Dept. Computer Applications
Presented by:
Basil N G
Roll No:17
MCA S5 R
Go is a programming language
designed by Google to help
solve Google's problems.
What is Go?
And has big
problems!
Which (big) problems?
● Hardware is big and the software is big
● There are many millions of lines of software
● Servers mostly in C++ and lots of Java and Python
● Thousands of engineers work on the code
● And of course, all this software runs on zillions of
machines.
A lot of others people
help to bring go from
prototype to reality.
Go became a public
Open Source
project.
2008 2009 20102007
Starts to have
adoption by other
programmers
Started and built by
Robert Griesemer,
Rob Pike and Ken
Thompson as a
part-time project.
History
● Ken Thompson (B, C, Unix, UTF-8)
● Rob Pike (Unix, UTF-8)
● Robert Griesemer (Hotspot, JVM)
...and a few others engineers at Google
Who were the founders?
● Eliminate slowness
● Eliminate clumsiness
● Improve productive
● Maintain (and improve) scale
It was designed by and for people who write, read,
debug and maintain large software systems.
Go's purpose is not to do research programming
language design.
Go's purpose is to make its designers' programming
lives better.
Why Go?
Go is a compiled, concurrent,
garbage-collected, statically typed
language developed at .
What is Go?
build
run
clean
env
test
compile packages and dependencies
compile and run Go program
remove object files
print Go environment information
test packages and benchmarks
Go is a tool for managing Go source code...
Mainly tools:
Others tools:
fix, fmt, get, install, list, tool,
version, vet.
Who are using today?
https://github.com/golang/go/wiki/GoUsers
❏ Compiled
❏ Garbage-collected
❏ Has your own runtime
❏ Simple syntax
❏ Great standard library
❏ Cross-platform
❏ Object Oriented (without inheritance)
❏ Statically and stronger typed
❏ Concurrent (goroutines)
❏ Closures
❏ Explicity dependencies
❏ Multiple return values
❏ Pointers
❏ and so on...
What will you see in Go?
Have not been implemented in
favor of efficiency.
❏ Exception handling
❏ Inheritance
❏ Generics
❏ Assert
❏ Method overload
What will you not
see in Go?
see a bit of code!
A Go program basically consists of
the following parts :−
Package Declaration
Import Packages
Functions
Variables
Statements and Expressions
Comments
Sample Program
package main
import "fmt“
func main() {
/* This is my first sample program. */
fmt.Println("Hello, World!")
}
Go - Data Types
Boolean types
They are Boolean types and consists of the two predefined
constants: (a) true (b) false
Eg: var abc bool = true
Numeric types
They are arithmetic types and they represents
a) integer types (uint8-uint64, int8-int64, byte, rune, uint, int
b) floating point values (float32-float64)
(complex64-complex128)
Eg: var num int32 = -123
Contd…
String types
A string type represents the set of string values.
Its value is a sequence of bytes.
Eg: var str string =“hello”
Derived types
They include (a) Pointer types, (b) Array types, (c) Structure types,
(d) Union types (e) Function types f) Slice types g) Function types
h) Interface types i) Map types j) Channel Types
Go - Operators
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Miscellaneous Operators
Operator Meaning
= = equal to
!= Not Equal to
< Less than
> Greater than
<= Less than or
equal to
>= Greater than or
equal to
Operator Meaning
+ add
- Subtraction
* Multiplication
/ Division
% modulus
++ Increment
-- Decrement
1. Arithmetic Operators 2.Relational Operators
Operator Meaning
&& Logical AND
| | Logical OR
! Logical NOT
Operator Meaning
& Logical AND
| Logical OR
^ Logical NOT
<< Binary Left Shift
>> Binary Right Shift
3.Logical operators 4.Bitwise operators
5.Miscellaneous Operators
Operator Meaning
& Returns the address of a variable
* Pointer to a variable
Go – Decision Making
if statement
Consists of a boolean expression followed by one or more
statements.
package main
import "fmt“
func main() {
if n:=8; n%4 == 0 {
fmt.Println("8 is divisible by 4")
}
}
There is also if... else and nested if statements
switch statement
A switch statement allows a variable to be tested
for equality against a list of values.
os := "wndows"
switch os {
case "darwin":
fmt.Println("OS X.")
case "linux":
fmt.Println("Linux.")
default:
fmt.Printf("%s.", os)
}
Contd…
Go- Loops
For Loop
It executes a sequence of statements multiple times and
abbreviates the code that manages the loop variable.
• Go has just for as looping structure
• It is very similar with C or Java code, except for ( )
• Start and end declarations can be empty
Eg: for i:=0;i<5;i++ {
fmt.Printf("%d",i)
if i==3 {
fmt.Println("bye")
break
}
}
For is Go's "while“
At that point you can drop the semicolons: C's while is
spelled for in Go.
Eg: sum := 1
for sum <= 10 {
sum += sum
}
fmt.Println(sum)
Forever
If you omit the loop condition it loops forever, so an infinite
loop is compactly expressed.
Eg: for{
}
The deferred call's arguments are evaluated immediately, but the
function call is not executed until the surrounding function
returns.
func main() {
defer fmt.Println("world")
fmt.Println("hello")
}
Defer
Go - Functions
func function_name( [parameter list] ) [return_types] {
body of the function
}
• A function declaration binds an identifier,
the function name, to a function.
• Multiple return values
• Named result parameters
Go – Multiple Return Values
func swap(x, y string) (string, string) {
return y, x
}
func main() {
a, b := swap("hello", "world")
fmt.Println(a, b)
}
One of Go's unusual features is that functions and
methods can return multiple values.
What more?
● Pointer
● Struct
● Matrix
● Slice
● Range
● Closure //func inside a func
● Map
● Value function
● Method
● Interface
● Stringer
● Error
● and a lot of more!!!
$ go run http.go
A web server
● It is just simple to build a web server with 15 lines or less!!
Could you belive that???
● To execute a goroutine, just go!
● To send or receive information between the
goroutines, use channels
● Use the GOMAXPROCS environment variable to
define the amount of threads
Concurrency (goroutines)
$ go run goroutines.go
hello
world
hello
world
hello
world
hello
world
hello
● A goroutine is a lightweight thread managed by Go runtime
Goroutines
$ go run channels.go
17 -5 12
Channels
● Channels are typed's conduit through which you can send and receive
values with the channel operator <-
Unbuffered Channels
c := make (chan int)
Buffered Channels
c := make (chan int, 10)
Conclusion
•In 2014, analyst Donnie Berkholz called Go the emerging language of
cloud infrastructure. By 2017, Go has emerged as the language of
cloud infrastructure. Today, every single cloud company has
critical components of their cloud infrastructure implemented in
Go including Google Cloud, AWS, Microsoft Azure and many more
•In Stack Overflow's 2017 developer survey , Go was the only
language that was both on the top 5 most loved and top 5 most
wanted languages. People who use Go, love it, and the people who
aren’t using Go, want to be.
References
Go websites:
Official:
https://golang.org/
Documents:
http://golang.org/doc/effective_go.html
https://blog.golang.org/
Video & Programs:
http://www.newthinktank.com/2015/02/go-
programming-tutorial/
Questions?
Thanks

More Related Content

What's hot (20)

PDF
The Go programming language - Intro by MyLittleAdventure
mylittleadventure
 
PDF
Go language presentation
paramisoft
 
PDF
Coding with golang
HannahMoss14
 
PDF
Golang and Eco-System Introduction / Overview
Markus Schneider
 
PPTX
Go. Why it goes
Sergey Pichkurov
 
PPTX
Introduction to GoLang
NVISIA
 
PPTX
Go Language presentation
Gh-Mohammed Eldadah
 
PDF
Golang 101
宇 傅
 
PDF
Go Programming Language by Google
Uttam Gandhi
 
PDF
Introduction to Go programming language
Slawomir Dorzak
 
PPTX
Go Programming Language (Golang)
Ishin Vin
 
PDF
Why you should care about Go (Golang)
Aaron Schlesinger
 
PDF
Goroutines and Channels in practice
Guilherme Garnier
 
PDF
Introduction to go language programming
Mahmoud Masih Tehrani
 
PPT
GO programming language
tung vu
 
PDF
Golang workshop
Victor S. Recio
 
PPTX
Go vs Python Comparison
Simplilearn
 
PPTX
Write microservice in golang
Bo-Yi Wu
 
PDF
Go Concurrency
jgrahamc
 
PDF
Introduction to Go language
Tzar Umang
 
The Go programming language - Intro by MyLittleAdventure
mylittleadventure
 
Go language presentation
paramisoft
 
Coding with golang
HannahMoss14
 
Golang and Eco-System Introduction / Overview
Markus Schneider
 
Go. Why it goes
Sergey Pichkurov
 
Introduction to GoLang
NVISIA
 
Go Language presentation
Gh-Mohammed Eldadah
 
Golang 101
宇 傅
 
Go Programming Language by Google
Uttam Gandhi
 
Introduction to Go programming language
Slawomir Dorzak
 
Go Programming Language (Golang)
Ishin Vin
 
Why you should care about Go (Golang)
Aaron Schlesinger
 
Goroutines and Channels in practice
Guilherme Garnier
 
Introduction to go language programming
Mahmoud Masih Tehrani
 
GO programming language
tung vu
 
Golang workshop
Victor S. Recio
 
Go vs Python Comparison
Simplilearn
 
Write microservice in golang
Bo-Yi Wu
 
Go Concurrency
jgrahamc
 
Introduction to Go language
Tzar Umang
 

Similar to Go Programming language, golang (20)

PPTX
Go programming introduction
Ginto Joseph
 
PDF
An introduction to programming in Go
David Robert Camargo de Campos
 
PPTX
go language- haseeb.pptx
ArsalanMaqsood1
 
PPT
Introduction to Go ProgrammingLanguage.ppt
PedroAlexandre215482
 
PPTX
Golang
Fatih Şimşek
 
PDF
The GO programming language
Marco Sabatini
 
PDF
Introduction to Programming in Go
Amr Hassan
 
PPT
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
PPT
Google's Go Programming Language - Introduction
Ganesh Samarthyam
 
PDF
Golang
Saray Chak
 
PPTX
Go fundamentals
Ron Barabash
 
PPTX
Go Language Hands-on Workshop Material
Romin Irani
 
PDF
Inroduction to golang
Yoni Davidson
 
PPTX
The GO Language : From Beginners to Gophers
I.I.S. G. Vallauri - Fossano
 
PPTX
Lab1GoBasicswithgo_foundationofgolang.pptx
stasneemattia
 
PDF
Introduction to Go
Simon Hewitt
 
PPTX
Should i Go there
Shimi Bandiel
 
PDF
Go Programming by Example_ Nho Vĩnh Share.pdf
Nho Vĩnh
 
PPTX
Go programing language
Ramakrishna kapa
 
PPTX
Golang introduction
DineshDinesh131
 
Go programming introduction
Ginto Joseph
 
An introduction to programming in Go
David Robert Camargo de Campos
 
go language- haseeb.pptx
ArsalanMaqsood1
 
Introduction to Go ProgrammingLanguage.ppt
PedroAlexandre215482
 
The GO programming language
Marco Sabatini
 
Introduction to Programming in Go
Amr Hassan
 
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
Google's Go Programming Language - Introduction
Ganesh Samarthyam
 
Golang
Saray Chak
 
Go fundamentals
Ron Barabash
 
Go Language Hands-on Workshop Material
Romin Irani
 
Inroduction to golang
Yoni Davidson
 
The GO Language : From Beginners to Gophers
I.I.S. G. Vallauri - Fossano
 
Lab1GoBasicswithgo_foundationofgolang.pptx
stasneemattia
 
Introduction to Go
Simon Hewitt
 
Should i Go there
Shimi Bandiel
 
Go Programming by Example_ Nho Vĩnh Share.pdf
Nho Vĩnh
 
Go programing language
Ramakrishna kapa
 
Golang introduction
DineshDinesh131
 
Ad

Recently uploaded (20)

PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
Human Resources Information System (HRIS)
Amity University, Patna
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Import Data Form Excel to Tally Services
Tally xperts
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Tally software_Introduction_Presentation
AditiBansal54083
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
Ad

Go Programming language, golang

  • 1. The Go Programming Language Seminar Guide: Ms. Alby S. Assistant Professor Dept. Computer Applications Presented by: Basil N G Roll No:17 MCA S5 R
  • 2. Go is a programming language designed by Google to help solve Google's problems. What is Go? And has big problems!
  • 3. Which (big) problems? ● Hardware is big and the software is big ● There are many millions of lines of software ● Servers mostly in C++ and lots of Java and Python ● Thousands of engineers work on the code ● And of course, all this software runs on zillions of machines.
  • 4. A lot of others people help to bring go from prototype to reality. Go became a public Open Source project. 2008 2009 20102007 Starts to have adoption by other programmers Started and built by Robert Griesemer, Rob Pike and Ken Thompson as a part-time project. History
  • 5. ● Ken Thompson (B, C, Unix, UTF-8) ● Rob Pike (Unix, UTF-8) ● Robert Griesemer (Hotspot, JVM) ...and a few others engineers at Google Who were the founders?
  • 6. ● Eliminate slowness ● Eliminate clumsiness ● Improve productive ● Maintain (and improve) scale It was designed by and for people who write, read, debug and maintain large software systems. Go's purpose is not to do research programming language design. Go's purpose is to make its designers' programming lives better. Why Go?
  • 7. Go is a compiled, concurrent, garbage-collected, statically typed language developed at . What is Go?
  • 8. build run clean env test compile packages and dependencies compile and run Go program remove object files print Go environment information test packages and benchmarks Go is a tool for managing Go source code... Mainly tools: Others tools: fix, fmt, get, install, list, tool, version, vet.
  • 9. Who are using today? https://github.com/golang/go/wiki/GoUsers
  • 10. ❏ Compiled ❏ Garbage-collected ❏ Has your own runtime ❏ Simple syntax ❏ Great standard library ❏ Cross-platform ❏ Object Oriented (without inheritance) ❏ Statically and stronger typed ❏ Concurrent (goroutines) ❏ Closures ❏ Explicity dependencies ❏ Multiple return values ❏ Pointers ❏ and so on... What will you see in Go?
  • 11. Have not been implemented in favor of efficiency. ❏ Exception handling ❏ Inheritance ❏ Generics ❏ Assert ❏ Method overload What will you not see in Go?
  • 12. see a bit of code!
  • 13. A Go program basically consists of the following parts :− Package Declaration Import Packages Functions Variables Statements and Expressions Comments
  • 14. Sample Program package main import "fmt“ func main() { /* This is my first sample program. */ fmt.Println("Hello, World!") }
  • 15. Go - Data Types Boolean types They are Boolean types and consists of the two predefined constants: (a) true (b) false Eg: var abc bool = true Numeric types They are arithmetic types and they represents a) integer types (uint8-uint64, int8-int64, byte, rune, uint, int b) floating point values (float32-float64) (complex64-complex128) Eg: var num int32 = -123
  • 16. Contd… String types A string type represents the set of string values. Its value is a sequence of bytes. Eg: var str string =“hello” Derived types They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types (e) Function types f) Slice types g) Function types h) Interface types i) Map types j) Channel Types
  • 17. Go - Operators Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Miscellaneous Operators
  • 18. Operator Meaning = = equal to != Not Equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to Operator Meaning + add - Subtraction * Multiplication / Division % modulus ++ Increment -- Decrement 1. Arithmetic Operators 2.Relational Operators
  • 19. Operator Meaning && Logical AND | | Logical OR ! Logical NOT Operator Meaning & Logical AND | Logical OR ^ Logical NOT << Binary Left Shift >> Binary Right Shift 3.Logical operators 4.Bitwise operators 5.Miscellaneous Operators Operator Meaning & Returns the address of a variable * Pointer to a variable
  • 20. Go – Decision Making if statement Consists of a boolean expression followed by one or more statements. package main import "fmt“ func main() { if n:=8; n%4 == 0 { fmt.Println("8 is divisible by 4") } } There is also if... else and nested if statements
  • 21. switch statement A switch statement allows a variable to be tested for equality against a list of values. os := "wndows" switch os { case "darwin": fmt.Println("OS X.") case "linux": fmt.Println("Linux.") default: fmt.Printf("%s.", os) } Contd…
  • 22. Go- Loops For Loop It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. • Go has just for as looping structure • It is very similar with C or Java code, except for ( ) • Start and end declarations can be empty Eg: for i:=0;i<5;i++ { fmt.Printf("%d",i) if i==3 { fmt.Println("bye") break } }
  • 23. For is Go's "while“ At that point you can drop the semicolons: C's while is spelled for in Go. Eg: sum := 1 for sum <= 10 { sum += sum } fmt.Println(sum) Forever If you omit the loop condition it loops forever, so an infinite loop is compactly expressed. Eg: for{ }
  • 24. The deferred call's arguments are evaluated immediately, but the function call is not executed until the surrounding function returns. func main() { defer fmt.Println("world") fmt.Println("hello") } Defer
  • 25. Go - Functions func function_name( [parameter list] ) [return_types] { body of the function } • A function declaration binds an identifier, the function name, to a function. • Multiple return values • Named result parameters
  • 26. Go – Multiple Return Values func swap(x, y string) (string, string) { return y, x } func main() { a, b := swap("hello", "world") fmt.Println(a, b) } One of Go's unusual features is that functions and methods can return multiple values.
  • 27. What more? ● Pointer ● Struct ● Matrix ● Slice ● Range ● Closure //func inside a func ● Map ● Value function ● Method ● Interface ● Stringer ● Error ● and a lot of more!!!
  • 28. $ go run http.go A web server ● It is just simple to build a web server with 15 lines or less!! Could you belive that???
  • 29. ● To execute a goroutine, just go! ● To send or receive information between the goroutines, use channels ● Use the GOMAXPROCS environment variable to define the amount of threads Concurrency (goroutines)
  • 30. $ go run goroutines.go hello world hello world hello world hello world hello ● A goroutine is a lightweight thread managed by Go runtime Goroutines
  • 31. $ go run channels.go 17 -5 12 Channels ● Channels are typed's conduit through which you can send and receive values with the channel operator <-
  • 32. Unbuffered Channels c := make (chan int)
  • 33. Buffered Channels c := make (chan int, 10)
  • 34. Conclusion •In 2014, analyst Donnie Berkholz called Go the emerging language of cloud infrastructure. By 2017, Go has emerged as the language of cloud infrastructure. Today, every single cloud company has critical components of their cloud infrastructure implemented in Go including Google Cloud, AWS, Microsoft Azure and many more •In Stack Overflow's 2017 developer survey , Go was the only language that was both on the top 5 most loved and top 5 most wanted languages. People who use Go, love it, and the people who aren’t using Go, want to be.