SlideShare a Scribd company logo
A Very Brief Intro to Golang
joshua@hauptj.com
Notable projects that use it
• Kubernetes
• Kubernetes – Helm
• Docker
• Packer
• Terraform
• Tekton
Why it exists
• Google needed a simple programming language that scaled and
performed well for distributed systems at a large scale.
Designed with simplicity in mind
• All loops are declared with for
• Composition over inheritance
• Python like array operations
• Encapsulation declared by case
• Built in garbage collection
• Package manager, linter, auto formatter, and unit testing framework
all packaged together
Composition over Inheritance
• Inheritance is not supported
type Building struct(){
Door
Name string
}
Type Door struct(){
Location string
}
Loops
• For, while and do while are all declared with for
For Loop
for i := 0; i < 10; i++ {
sum += i
}
Range
• Iterates over a slice or map
• Like for each in Python
for i range slice {
fmt.printf(i)
}
While loop
for sum < 1000 {
sum += sum
}
Variables
• A list of variables can be declared with var
• Like Javascript
• Can be set automatically, life python and JS
Number = balance(input int) int {
Return input
}
Slices
• A dynamically sized flexible view of the elements in an Array
• numbers := [6]int{1, 2, 3, 4, 5, 6}
• A[low / left : high / right]
• Like python
• var s []int = numbers[1:4]
• Output: 2, 3, 4
Short Variable Declarations
number := balance(input int) int {
Return input
}
Loops
• For, while and do while are all declared with for
For Loop
for i := 0; i < 10; i++ {
sum += i
}
While Loop
for sum < 1000 {
sum += sum
}
Range
• Iterates over a slice or map
• Like “for each” in Python
for i range slice {
fmt.printf(i)
}
•Iterates over a slice or map
•Like "for each" each in Python
Slices
• A dynamically sized flexible view of the elements in an Array
• numbers := [6]int{1, 2, 3, 4, 5, 6}
• A[low / left : high / right]
• Like python
• var s []int = numbers[1:4]
• Output: 2, 3, 4
•Like python
•var s []int = numbers[1:4]
•Output: 2, 3, 4
Composition over Inheritance
• Inheritance is not supported
• Like in React JS
Encapsulation
• Encapsulation is case sensitive
• Capitalized - public
• non capitialized - private
Encapsulation Example
type Building struct() {
Door
Name string
}
type Door struct() {
Location string
}
Pointers
• Holds the memory address of a value
• Like C
• However, Go does not support pointer arithmetic
• var *ptr int
• prt++
Defer
• Defers the execution of a function until the surrounding function
returns.
func main() {
Defer fmt.Println(“world”)
Fmt.Println(“hello”)
}
Unused Imports?
• Compiler will refuse to compile.
• Encourages good practices
Everything Bundled Together
• Package Manager
• go get package name
• Testing framework
• go test
• Code formatter
• go fmt
Concurrency Example
func main()
messages := make(chan string)
go func() { messages <- “Hello World” }()
msg := <- messages
fmt.Println(msg)
}
Concurrency
• Communicating Sequential Processes (CSP)
• Goroutines: “lightweight threats” that allow functions to run
concurrently
• Channels: Used to pass messages between goroutines
Recommended Resources Cont. - Testing
• A Tour of Go
• Go by Example
• Common data structures in Go
• Regular Expressions and In-Place Slice Manipulation in Go
• Traversing Directories Recursively and Sorting Objects by Attribute
Value in Go
Recommended Resources Cont.
• https://medium.com/rungo/unit-testing-made-easy-in-go-
25077669318
• https://medium.com/rate-engineering/go-test-your-code-an-
introduction-to-effective-testing-in-go-6e4f66f2c259
Questions?

More Related Content

PDF
Computer network (6)
PDF
CNIT 127: Ch 4: Introduction to format string bugs
PPTX
F# for Trading
PDF
CNIT 127: Ch 8: Windows overflows (Part 2)
PDF
CNIT 127: Ch 2: Stack overflows on Linux
ZIP
なぜ検索しなかったのか
PPTX
test
PDF
CNIT 127 Ch 5: Introduction to heap overflows
Computer network (6)
CNIT 127: Ch 4: Introduction to format string bugs
F# for Trading
CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 2: Stack overflows on Linux
なぜ検索しなかったのか
test
CNIT 127 Ch 5: Introduction to heap overflows

What's hot (20)

PDF
Be a Zen monk, the Python way
PDF
CNIT 127: Ch 18: Source Code Auditing
PDF
CNIT 127 Ch 1: Before you Begin
PDF
Dynamic pricing of Lyft rides using streaming
PDF
Esri International User Conference 2011: Python: Integrating Standard and Thi...
PDF
CNIT 127: Ch 3: Shellcode
PDF
127 Ch 2: Stack overflows on Linux
PDF
CNIT 127 Ch 2: Stack overflows on Linux
PDF
Return Oriented Programming
PDF
Whirlwind tour of the Runtime Dynamic Linker
PPTX
Demo learn python
PDF
CNIT 127: Ch 8: Windows overflows (Part 1)
PDF
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
PPTX
Introduction to Basic Memory Management C++
PPTX
Python Applications
PPTX
xlwings performance
PDF
From zero to gremlin hero - Part I
PDF
Go at uber
PDF
CNIT 126 5: IDA Pro
PPTX
0.5mln packets per second with Erlang
Be a Zen monk, the Python way
CNIT 127: Ch 18: Source Code Auditing
CNIT 127 Ch 1: Before you Begin
Dynamic pricing of Lyft rides using streaming
Esri International User Conference 2011: Python: Integrating Standard and Thi...
CNIT 127: Ch 3: Shellcode
127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on Linux
Return Oriented Programming
Whirlwind tour of the Runtime Dynamic Linker
Demo learn python
CNIT 127: Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
Introduction to Basic Memory Management C++
Python Applications
xlwings performance
From zero to gremlin hero - Part I
Go at uber
CNIT 126 5: IDA Pro
0.5mln packets per second with Erlang
Ad

Similar to A Very Brief Intro to Golang (20)

PDF
Lecture 1 - Overview of Go Language 1.pdf
PPT
Javascript
PPTX
Should i Go there
PPTX
C++ overview
PPTX
Fundamentals of Python Programming
PPTX
Dr.C S Prasanth-Physics ppt.pptx computer
PDF
#Pharo Days 2016 Data Formats and Protocols
PPTX
Go from a PHP Perspective
PPTX
What is Python?
PPTX
Python programming
PPTX
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
PDF
prakash ppt (2).pdf
PPTX
PPTX
2CPP17 - File IO
PPTX
How to Write the Fastest JSON Parser/Writer in the World
PDF
Serving Deep Learning Models At Scale With RedisAI: Luca Antiga
PDF
A Peek into TFRT
PPTX
Core java complete ppt(note)
PDF
Learn C program in Complete c programing string and its functions like array...
PPTX
PigHive.pptx
Lecture 1 - Overview of Go Language 1.pdf
Javascript
Should i Go there
C++ overview
Fundamentals of Python Programming
Dr.C S Prasanth-Physics ppt.pptx computer
#Pharo Days 2016 Data Formats and Protocols
Go from a PHP Perspective
What is Python?
Python programming
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
prakash ppt (2).pdf
2CPP17 - File IO
How to Write the Fastest JSON Parser/Writer in the World
Serving Deep Learning Models At Scale With RedisAI: Luca Antiga
A Peek into TFRT
Core java complete ppt(note)
Learn C program in Complete c programing string and its functions like array...
PigHive.pptx
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
L1 - Introduction to python Backend.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Digital Strategies for Manufacturing Companies
PPTX
CHAPTER 2 - PM Management and IT Context
PPT
Introduction Database Management System for Course Database
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
ai tools demonstartion for schools and inter college
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Introduction to Artificial Intelligence
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Odoo Companies in India – Driving Business Transformation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Design an Analysis of Algorithms II-SECS-1021-03
L1 - Introduction to python Backend.pptx
history of c programming in notes for students .pptx
Digital Strategies for Manufacturing Companies
CHAPTER 2 - PM Management and IT Context
Introduction Database Management System for Course Database
Understanding Forklifts - TECH EHS Solution
ai tools demonstartion for schools and inter college
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Adobe Illustrator 28.6 Crack My Vision of Vector Design
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Computer Software and OS of computer science of grade 11.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction to Artificial Intelligence

A Very Brief Intro to Golang

  • 1. A Very Brief Intro to Golang joshua@hauptj.com
  • 2. Notable projects that use it • Kubernetes • Kubernetes – Helm • Docker • Packer • Terraform • Tekton
  • 3. Why it exists • Google needed a simple programming language that scaled and performed well for distributed systems at a large scale.
  • 4. Designed with simplicity in mind • All loops are declared with for • Composition over inheritance • Python like array operations • Encapsulation declared by case • Built in garbage collection • Package manager, linter, auto formatter, and unit testing framework all packaged together
  • 5. Composition over Inheritance • Inheritance is not supported type Building struct(){ Door Name string } Type Door struct(){ Location string }
  • 6. Loops • For, while and do while are all declared with for
  • 7. For Loop for i := 0; i < 10; i++ { sum += i }
  • 8. Range • Iterates over a slice or map • Like for each in Python for i range slice { fmt.printf(i) }
  • 9. While loop for sum < 1000 { sum += sum }
  • 10. Variables • A list of variables can be declared with var • Like Javascript • Can be set automatically, life python and JS Number = balance(input int) int { Return input }
  • 11. Slices • A dynamically sized flexible view of the elements in an Array • numbers := [6]int{1, 2, 3, 4, 5, 6} • A[low / left : high / right] • Like python • var s []int = numbers[1:4] • Output: 2, 3, 4
  • 12. Short Variable Declarations number := balance(input int) int { Return input }
  • 13. Loops • For, while and do while are all declared with for
  • 14. For Loop for i := 0; i < 10; i++ { sum += i }
  • 15. While Loop for sum < 1000 { sum += sum }
  • 16. Range • Iterates over a slice or map • Like “for each” in Python for i range slice { fmt.printf(i) } •Iterates over a slice or map •Like "for each" each in Python
  • 17. Slices • A dynamically sized flexible view of the elements in an Array • numbers := [6]int{1, 2, 3, 4, 5, 6} • A[low / left : high / right] • Like python • var s []int = numbers[1:4] • Output: 2, 3, 4 •Like python •var s []int = numbers[1:4] •Output: 2, 3, 4
  • 18. Composition over Inheritance • Inheritance is not supported • Like in React JS
  • 19. Encapsulation • Encapsulation is case sensitive • Capitalized - public • non capitialized - private
  • 20. Encapsulation Example type Building struct() { Door Name string } type Door struct() { Location string }
  • 21. Pointers • Holds the memory address of a value • Like C • However, Go does not support pointer arithmetic • var *ptr int • prt++
  • 22. Defer • Defers the execution of a function until the surrounding function returns. func main() { Defer fmt.Println(“world”) Fmt.Println(“hello”) }
  • 23. Unused Imports? • Compiler will refuse to compile. • Encourages good practices
  • 24. Everything Bundled Together • Package Manager • go get package name • Testing framework • go test • Code formatter • go fmt
  • 25. Concurrency Example func main() messages := make(chan string) go func() { messages <- “Hello World” }() msg := <- messages fmt.Println(msg) }
  • 26. Concurrency • Communicating Sequential Processes (CSP) • Goroutines: “lightweight threats” that allow functions to run concurrently • Channels: Used to pass messages between goroutines
  • 27. Recommended Resources Cont. - Testing • A Tour of Go • Go by Example • Common data structures in Go • Regular Expressions and In-Place Slice Manipulation in Go • Traversing Directories Recursively and Sorting Objects by Attribute Value in Go
  • 28. Recommended Resources Cont. • https://medium.com/rungo/unit-testing-made-easy-in-go- 25077669318 • https://medium.com/rate-engineering/go-test-your-code-an- introduction-to-effective-testing-in-go-6e4f66f2c259