SlideShare a Scribd company logo
Development with Go
- Manjitsing K. Valvi
GO Loops
for loop
● Only looping construct
● Three components
○ Init statement : executed at start of loop
○ Condition expression : executed before every iteration
○ Post statement : executed ar end of every iteration
● No parentheses for three conditions, function body inside { }
● Init and post statements are optional
Go for loops example
package main
import "fmt"
func main() {
sum := 0
for i := 0; i < 10; i++ {
sum += i
}
fmt.Println(sum)
}
Go for loops example
package main
import "fmt"
func main() {
sum := 1
for ; sum < 10; {
sum += sum
}
fmt.Println(sum)
}
GO Conditions
If
● No parentheses for conditions, body inside { }
● Short expression can be used in go, having scope in “if” only
● If can be paired with else as well, else body inside { }
GO Conditions
Switch case
● Evaluates cases from top to bottom
● Switch can have no condition => switch true
GO iteration
range
● iterates over elements in a variety of data structures
● range on arrays and slices provides both the index and value for each entry
● range on map iterates over key/value pairs
● range can also iterate over just the keys of a map
● range on strings iterates over Unicode code points
○ first value is the starting byte index of the rune and the second the rune
itself
References
● “The Way to Go: A Thorough Introduction to the Go Programming Language”,
● https://tour.golang.org/moretypes/
● https://gobyexample.com/
●

More Related Content

PPTX
Fifth session
PPTX
Lecture 4
PPTX
Lecture 3
PPT
Loops (1)
PDF
GDB tutorial
PDF
[C++ korea] effective modern c++ study item 4 - 6 신촌
PPTX
C# Loops
PPTX
Vim knowhow
Fifth session
Lecture 4
Lecture 3
Loops (1)
GDB tutorial
[C++ korea] effective modern c++ study item 4 - 6 신촌
C# Loops
Vim knowhow

What's hot (20)

PDF
CL metaprogramming
PPTX
C++11 move semantics
PDF
PPTX
Workshop 05 Review
PPTX
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
PPTX
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
PPTX
Class 25: Reversing Reverse
PPTX
Unit 3 stack
PPT
Stack application
PDF
Using zone.js
ODP
Extreme JavaScript Minification and Obfuscation
PPTX
push down automata
PPTX
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
PPTX
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
PPTX
Application of Stack - Yadraj Meena
TXT
참고 코드(Shelllilst filtering)
DOCX
Call by value and call by reference and varaiable length arguments
ODP
operating system (process)
PPTX
Reacting with ReactiveUI
PPTX
C Language - Switch and For Loop
CL metaprogramming
C++11 move semantics
Workshop 05 Review
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
Class 25: Reversing Reverse
Unit 3 stack
Stack application
Using zone.js
Extreme JavaScript Minification and Obfuscation
push down automata
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
Application of Stack - Yadraj Meena
참고 코드(Shelllilst filtering)
Call by value and call by reference and varaiable length arguments
operating system (process)
Reacting with ReactiveUI
C Language - Switch and For Loop
Ad

Similar to Basic constructs ii (20)

PPTX
SwitchandlomahsjhASSJjajdjsdjdjjjop.pptx
PDF
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
PPTX
Lec7 - Loops updated.pptx
PPT
Chapter 5 Looping
PDF
[ITP - Lecture 11] Loops in C/C++
PPTX
Introduction& Overview-to-C++_programming.pptx
PPTX
Introduction to C++ programming language
PPTX
Python Revision Tour 1 Class XII CS
PPS
Programming in Arduino (Part 2)
PPTX
Chapter 2-Python and control flow statement.pptx
PPTX
Condition Stmt n Looping stmt.pptx
PDF
Python Programming Module 3 (2).pdf
PPTX
12-Lec - Repetition For Loop.pptx
PPTX
Programming in java - Concepts- Operators- Control statements-Expressions
PPT
Csc1100 lecture05 ch05
PPTX
C++ decision making
PPTX
C Programming Control Structures(if,if-else)
PDF
Python functions and loops
PDF
basic of desicion control statement in python
PDF
ICP - Lecture 9
SwitchandlomahsjhASSJjajdjsdjdjjjop.pptx
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Lec7 - Loops updated.pptx
Chapter 5 Looping
[ITP - Lecture 11] Loops in C/C++
Introduction& Overview-to-C++_programming.pptx
Introduction to C++ programming language
Python Revision Tour 1 Class XII CS
Programming in Arduino (Part 2)
Chapter 2-Python and control flow statement.pptx
Condition Stmt n Looping stmt.pptx
Python Programming Module 3 (2).pdf
12-Lec - Repetition For Loop.pptx
Programming in java - Concepts- Operators- Control statements-Expressions
Csc1100 lecture05 ch05
C++ decision making
C Programming Control Structures(if,if-else)
Python functions and loops
basic of desicion control statement in python
ICP - Lecture 9
Ad

More from Manjitsing Valvi (17)

PDF
Composite types
PDF
Basic types
PDF
Basic constructs i
PDF
Introduction to golang
PDF
Features of go
PDF
Error handling
PDF
Pointers & functions
PDF
Operators
PDF
PDF
Digital marketing marketing strategies for digital world
PDF
Digital marketing channels
PDF
Digital marketing techniques
PDF
Social media marketing &amp; managing cybersocial campaign
PDF
Creating marketing effective online store
PDF
Social media marketing tech tools and optimization for search engines
PDF
Digital marketing managing cybersocial campaign
PDF
Social media marketing
Composite types
Basic types
Basic constructs i
Introduction to golang
Features of go
Error handling
Pointers & functions
Operators
Digital marketing marketing strategies for digital world
Digital marketing channels
Digital marketing techniques
Social media marketing &amp; managing cybersocial campaign
Creating marketing effective online store
Social media marketing tech tools and optimization for search engines
Digital marketing managing cybersocial campaign
Social media marketing

Recently uploaded (20)

PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PPT on Performance Review to get promotions
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Geodesy 1.pptx...............................................
PDF
composite construction of structures.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPT
Project quality management in manufacturing
PPTX
web development for engineering and engineering
PPT
Mechanical Engineering MATERIALS Selection
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Artificial Intelligence
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Digital Logic Computer Design lecture notes
Safety Seminar civil to be ensured for safe working.
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Automation-in-Manufacturing-Chapter-Introduction.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT on Performance Review to get promotions
UNIT 4 Total Quality Management .pptx
Geodesy 1.pptx...............................................
composite construction of structures.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Project quality management in manufacturing
web development for engineering and engineering
Mechanical Engineering MATERIALS Selection
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Artificial Intelligence
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Digital Logic Computer Design lecture notes

Basic constructs ii

  • 1. Development with Go - Manjitsing K. Valvi
  • 2. GO Loops for loop ● Only looping construct ● Three components ○ Init statement : executed at start of loop ○ Condition expression : executed before every iteration ○ Post statement : executed ar end of every iteration ● No parentheses for three conditions, function body inside { } ● Init and post statements are optional
  • 3. Go for loops example package main import "fmt" func main() { sum := 0 for i := 0; i < 10; i++ { sum += i } fmt.Println(sum) }
  • 4. Go for loops example package main import "fmt" func main() { sum := 1 for ; sum < 10; { sum += sum } fmt.Println(sum) }
  • 5. GO Conditions If ● No parentheses for conditions, body inside { } ● Short expression can be used in go, having scope in “if” only ● If can be paired with else as well, else body inside { }
  • 6. GO Conditions Switch case ● Evaluates cases from top to bottom ● Switch can have no condition => switch true
  • 7. GO iteration range ● iterates over elements in a variety of data structures ● range on arrays and slices provides both the index and value for each entry ● range on map iterates over key/value pairs ● range can also iterate over just the keys of a map ● range on strings iterates over Unicode code points ○ first value is the starting byte index of the rune and the second the rune itself
  • 8. References ● “The Way to Go: A Thorough Introduction to the Go Programming Language”, ● https://tour.golang.org/moretypes/ ● https://gobyexample.com/ ●