Go is an open source programming language designed by Google to be concurrent, garbage collected, and efficient. It has a simple syntax and is used by Google and others to build large distributed systems. Key features include garbage collection, concurrency with goroutines and channels, interfaces without inheritance, and a large standard library.
This document provides an overview of the Go programming language, including its history, key features, syntax, and basic constructs. Go is an open source language developed by Google in 2007 for building simple, reliable and efficient software. It is syntactically similar to C, supports cross-platform development, and focuses on productivity for system programming and server-side applications. The document covers Go's essential qualities like being simple and well-defined, and provides examples of basic programming concepts in Go like variables, functions, conditionals, loops, arrays, slices, maps, structs and methods.
C++ is an object-oriented programming language that is based on C and adds object-oriented programming features like classes, inheritance, and polymorphism. It was created by Bjarne Stroustrup at Bell Labs in the early 1980s. The document provides an introduction to C++ including its history, differences from C, program structure, data types, variables, input/output, and integrated development environments.
- The document discusses Python programming concepts such as data types, variables, operators, and syntax. It provides examples of Python code for variables, comments, strings, numbers, and more.
- Python is a popular programming language used for web development, software development, mathematics, and more. It runs on different platforms and has a simple, readable syntax.
- Key features of Python include dynamic typing, automatic memory management, and an intuitive syntax that uses indentation rather than brackets.
The document discusses using the command line as a productivity tool. It presents bash as a powerful tool for automating tasks and introduces many useful commands and concepts, including redirection, pipes, variables, conditionals, loops, and scripting. It also summarizes tools for developers such as Homebrew, Git, Xcode, xcpretty and xctool.
Presentation with a brief history of C, C++ and their ancestors along with an introduction to latest version C++11 and futures such as C++17. The presentation covers applications that use C++, C++11 compilers such as LLVM/Clang, some of the new language features in C++11 and C++17 and examples of modern idioms such as the new form compressions, initializer lists, lambdas, compile time type identification, improved memory management and improved standard library (threads, math, random, chrono, etc). (less == more) || (more == more)
Python-Beginer-PartOnePython is one of the top programming languages in the w...ahmedosman389
Python is one of the top programming languages in the world, widely used in fields such as AI, machine learning, data science, and web development.
The simple and English-like syntax of Python makes it a go-to language for beginners who want to get into coding quickly.
Because Python is used in multiple fields, there is a high demand for Python developers, with competitive base salaries.
The document provides an overview of the basics of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented scripting language. It also covers Python's history and describes it as being easy to learn and read, easy to maintain, portable, and extensible. The document then details Python's core data types including numbers, strings, lists, tuples, and dictionaries. It provides examples of how to define and manipulate variables of each data type in Python.
The document introduces the Go programming language. It notes that Go was initially developed at Google and focuses on system programming, networking, and multi-core applications. Some key features of Go discussed include its C-like syntax, static typing, garbage collection, interfaces for object orientation, built-in concurrency using goroutines and channels, and its built-in testing framework. Real-world uses of Go at companies like Google, Heroku, and SoundCloud are also briefly mentioned. The presentation encourages giving Go a try for its benefits of being concurrent, networked, drawing from both dynamic and static languages, and its modern features.
The document provides an overview of the C programming language. It discusses basic C programming concepts like data types, variables, functions, pointers, structures, file handling and more. It also includes examples of basic C programs and code snippets to illustrate various programming concepts.
C++ is an object-oriented programming language that is an extension of C. It was created in 1979 and has undergone several revisions. C++ allows for faster development time and easier memory management compared to C due to features like code reuse, new data types, and object-oriented programming. The document provides an overview of C++ including its history, differences from C, program structure, data types, variables, input/output, and integrated development environments.
The document provides an overview of the C and C++ programming languages. It discusses the history and evolution of C and C++. It describes key features of C like procedural programming, manual memory management, and lack of object orientation. It also describes features of C++ like classes, inheritance, and templates which provide object orientation. The document lists many widely used software written in C/C++ and discusses advantages like speed and compact memory usage and disadvantages like difficulty of manual memory management. It provides examples of basic C code structures and data types.
Go is a general purpose programming language created by Google. It is statically typed, compiled, garbage collected, and memory safe. Go has good support for concurrency with goroutines and channels. It has a large standard library and integrates well with C. Some key differences compared to other languages are its performance, explicit concurrency model, and lack of classes. Common data types in Go include arrays, slices, maps, structs and interfaces.
This document provides an overview of the JavaScript programming language, including its history, key concepts, values, objects, and functions. It summarizes JavaScript as a dynamic language that unifies objects and functions, uses prototype-based inheritance, and loosely typed values. Everything in JavaScript is an object, which can be used to represent records, trees, and other data structures using dynamic object literals.
A short introduction to the Go programming language by Google, covering basic syntax, what it is used for and common applications that are written in it.
The document provides information about the Go programming language. It discusses the history and creators of Go, key features of the language such as concurrency and garbage collection, basic Go code examples, and common data types like slices and maps. It also covers Go tools, environments, benchmarks showing Go's performance, and examples of companies using Go in production.
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
Author: Oleg Godovykh, eastbanctech.com
Kotlin is a new programming language built by Jetbrains and is a new member of JVM family. As opposed to typical reason to introduce some new language, Kotlin main goal isn't to create new paradigm or fill a new niche, but to make routine tasks much easier and safer. Kotlin gains popularity across Android developer community, and in this presentation it is shown how Kotlin usage can dramatically simplify typical mobile app development.
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
This document provides an introduction to object-oriented programming concepts in C++ including objects, classes, encapsulation, inheritance, polymorphism, and more. It explains the basic structure of a C++ program and demonstrates how to write a simple "Hello World" program. It also covers basic C++ elements like variables, data types, comments, strings, arithmetic operators, and input/output.
This document provides an overview of using the bash shell as a productivity tool. It discusses using the terminal, basic bash usage including redirection, pipes, configuration files, keyboard shortcuts, history, and tab completion. Useful utilities like sed, awk, find, grep and scripting basics are covered. Tools for developers like Homebrew, Git, Xcode, and Cocoapods are also summarized. The document aims to help users "unleash their inner console cowboy" and do more work directly from the command line.
Python is an open source programming language created by Guido van Rossum in 1991. It is named after the comedy group Monty Python and is based on the ABC language. Python supports both procedural and object-oriented programming and can be used for web development, data analysis, artificial intelligence, and more. It has a simple syntax and large standard library that make it easy to learn and use for various applications.
Google's Go is a relatively new systems programming language that has recently gained a lot of traction with developers. It brings together the ease and efficiency of development in modern interpreted languages like Python, Perl, and Ruby with the efficiency and safety of a statically typed, compiled language like C/C++ and Java.
On top of that, Go is a language built for modern hardware and problems. With built-in support for concurrency, programmers can easily build software to scale up to today's many-core beasts. Programming in Go is really nice, and in this tutorial, you will learn why.
We will cover an introduction to the Go programming language, and together we will build a multi-user network service demonstrating all of the major principles of programming in Go.
#Pharo Days 2016 Data Formats and ProtocolsPhilippe Back
The document discusses various data formats and protocols for building bridges between Pharo and the outside world.
It describes common data formats like CSV, JSON, and XML that can be used to serialize and deserialize Pharo objects to and from streams. It provides examples of parsing and generating data in these formats using libraries like NeoCSV and NeoJSON.
It also discusses common protocols like HTTP, filesystem I/O, and subprocesses that can be used to communicate with external systems. Specific examples covered are the memcached protocol and using Zinc for HTTP client/server communication.
This document discusses upcoming features in C# based on presentations by Christian Nagel. It covers features already implemented in C# 7.x like tuples, deconstruction, and pattern matching as well as features still in progress or being prototyped for C# 8 like records, caller expression attributes, async streams, indexes and ranges, extended patterns, and nullable reference types. The goal of new features is to make C# code safer, more efficient, give more freedom, and require less code.
This document discusses programming languages and how computers execute code. It explains that high-level languages like Python, C++, and Java are translated into low-level machine language before the computer can run programs. It also discusses interpreters and compilers as tools that translate high-level code. The document then provides an introduction to the Python programming language, including basic Python vocabulary terms. It gives examples of Python code and explains concepts like variables, functions, operators, and data types.
1) Decorticate animal is the one without cerebral cortex
1) The preparation of decerebrate animal occurs because of the removal of all connections of cerebral hemispheres at the level of midbrain
The document provides an overview of the basics of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented scripting language. It also covers Python's history and describes it as being easy to learn and read, easy to maintain, portable, and extensible. The document then details Python's core data types including numbers, strings, lists, tuples, and dictionaries. It provides examples of how to define and manipulate variables of each data type in Python.
The document introduces the Go programming language. It notes that Go was initially developed at Google and focuses on system programming, networking, and multi-core applications. Some key features of Go discussed include its C-like syntax, static typing, garbage collection, interfaces for object orientation, built-in concurrency using goroutines and channels, and its built-in testing framework. Real-world uses of Go at companies like Google, Heroku, and SoundCloud are also briefly mentioned. The presentation encourages giving Go a try for its benefits of being concurrent, networked, drawing from both dynamic and static languages, and its modern features.
The document provides an overview of the C programming language. It discusses basic C programming concepts like data types, variables, functions, pointers, structures, file handling and more. It also includes examples of basic C programs and code snippets to illustrate various programming concepts.
C++ is an object-oriented programming language that is an extension of C. It was created in 1979 and has undergone several revisions. C++ allows for faster development time and easier memory management compared to C due to features like code reuse, new data types, and object-oriented programming. The document provides an overview of C++ including its history, differences from C, program structure, data types, variables, input/output, and integrated development environments.
The document provides an overview of the C and C++ programming languages. It discusses the history and evolution of C and C++. It describes key features of C like procedural programming, manual memory management, and lack of object orientation. It also describes features of C++ like classes, inheritance, and templates which provide object orientation. The document lists many widely used software written in C/C++ and discusses advantages like speed and compact memory usage and disadvantages like difficulty of manual memory management. It provides examples of basic C code structures and data types.
Go is a general purpose programming language created by Google. It is statically typed, compiled, garbage collected, and memory safe. Go has good support for concurrency with goroutines and channels. It has a large standard library and integrates well with C. Some key differences compared to other languages are its performance, explicit concurrency model, and lack of classes. Common data types in Go include arrays, slices, maps, structs and interfaces.
This document provides an overview of the JavaScript programming language, including its history, key concepts, values, objects, and functions. It summarizes JavaScript as a dynamic language that unifies objects and functions, uses prototype-based inheritance, and loosely typed values. Everything in JavaScript is an object, which can be used to represent records, trees, and other data structures using dynamic object literals.
A short introduction to the Go programming language by Google, covering basic syntax, what it is used for and common applications that are written in it.
The document provides information about the Go programming language. It discusses the history and creators of Go, key features of the language such as concurrency and garbage collection, basic Go code examples, and common data types like slices and maps. It also covers Go tools, environments, benchmarks showing Go's performance, and examples of companies using Go in production.
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
Author: Oleg Godovykh, eastbanctech.com
Kotlin is a new programming language built by Jetbrains and is a new member of JVM family. As opposed to typical reason to introduce some new language, Kotlin main goal isn't to create new paradigm or fill a new niche, but to make routine tasks much easier and safer. Kotlin gains popularity across Android developer community, and in this presentation it is shown how Kotlin usage can dramatically simplify typical mobile app development.
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
This document provides an introduction to object-oriented programming concepts in C++ including objects, classes, encapsulation, inheritance, polymorphism, and more. It explains the basic structure of a C++ program and demonstrates how to write a simple "Hello World" program. It also covers basic C++ elements like variables, data types, comments, strings, arithmetic operators, and input/output.
This document provides an overview of using the bash shell as a productivity tool. It discusses using the terminal, basic bash usage including redirection, pipes, configuration files, keyboard shortcuts, history, and tab completion. Useful utilities like sed, awk, find, grep and scripting basics are covered. Tools for developers like Homebrew, Git, Xcode, and Cocoapods are also summarized. The document aims to help users "unleash their inner console cowboy" and do more work directly from the command line.
Python is an open source programming language created by Guido van Rossum in 1991. It is named after the comedy group Monty Python and is based on the ABC language. Python supports both procedural and object-oriented programming and can be used for web development, data analysis, artificial intelligence, and more. It has a simple syntax and large standard library that make it easy to learn and use for various applications.
Google's Go is a relatively new systems programming language that has recently gained a lot of traction with developers. It brings together the ease and efficiency of development in modern interpreted languages like Python, Perl, and Ruby with the efficiency and safety of a statically typed, compiled language like C/C++ and Java.
On top of that, Go is a language built for modern hardware and problems. With built-in support for concurrency, programmers can easily build software to scale up to today's many-core beasts. Programming in Go is really nice, and in this tutorial, you will learn why.
We will cover an introduction to the Go programming language, and together we will build a multi-user network service demonstrating all of the major principles of programming in Go.
#Pharo Days 2016 Data Formats and ProtocolsPhilippe Back
The document discusses various data formats and protocols for building bridges between Pharo and the outside world.
It describes common data formats like CSV, JSON, and XML that can be used to serialize and deserialize Pharo objects to and from streams. It provides examples of parsing and generating data in these formats using libraries like NeoCSV and NeoJSON.
It also discusses common protocols like HTTP, filesystem I/O, and subprocesses that can be used to communicate with external systems. Specific examples covered are the memcached protocol and using Zinc for HTTP client/server communication.
This document discusses upcoming features in C# based on presentations by Christian Nagel. It covers features already implemented in C# 7.x like tuples, deconstruction, and pattern matching as well as features still in progress or being prototyped for C# 8 like records, caller expression attributes, async streams, indexes and ranges, extended patterns, and nullable reference types. The goal of new features is to make C# code safer, more efficient, give more freedom, and require less code.
This document discusses programming languages and how computers execute code. It explains that high-level languages like Python, C++, and Java are translated into low-level machine language before the computer can run programs. It also discusses interpreters and compilers as tools that translate high-level code. The document then provides an introduction to the Python programming language, including basic Python vocabulary terms. It gives examples of Python code and explains concepts like variables, functions, operators, and data types.
1) Decorticate animal is the one without cerebral cortex
1) The preparation of decerebrate animal occurs because of the removal of all connections of cerebral hemispheres at the level of midbrain
This presentation explores the application of Discrete Choice Experiments (DCEs) to evaluate public preferences for environmental enhancements to Airthrey Loch, a freshwater lake located on the University of Stirling campus. The study aims to identify the most valued ecological and recreational improvements—such as water quality, biodiversity, and access facilities by analyzing how individuals make trade-offs among various attributes. The results provide insights for policy-makers and campus planners to design sustainable and community-preferred interventions. This work bridges environmental economics and conservation strategy using empirical, choice-based data analysis.
Location of proprioceptors in labyrinth, muscles, tendons of muscles, joints, ligaments and fascia, different types of proprioceptors include muscle spindle, golgi tendon organ, pacinian corpuscle, free nerve endings, proprioceptors in labyrinth, nuclear bag fibers, nuclear chain fibers, nerve supply to muscle spindle, sensory nerve supply, motor nerve supply, functions of muscle spindle include stretch reflex, dynamic response, static response, physiologic tremor, role of muscle spindle in the maintenance of muscle tone, structure and nerve supply to golgi tendon organ, functions of golgi tendon organs include role of golgi tendon organ in forceful contraction, role in golgi tendon organ, role of golgi tendon organ in lengthening reactions, pacinian corpuscle and free nerve endings,
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...Sérgio Sacani
Tidal disruption events (TDEs) that are spatially offset from the nuclei of their host galaxies offer a new probe of massive black hole (MBH) wanderers, binaries, triples, and recoiling MBHs. Here we present AT2024tvd, the first off-nuclear TDE identified through optical sky surveys. High-resolution imaging with the Hubble Space Telescope shows that AT2024tvd is 0.914 ± 0.010′′ offset from the apparent center of its host galaxy, corresponding to a projected distance of 0.808 ± 0.009kpc at z = 0.045. Chandra and VLA observations support the same conclusion for the TDE’s X-ray and radio emission. AT2024tvd exhibits typical properties of nuclear TDEs, including a persistent hot UV/optical component that peaks at Lbb ∼ 6×1043ergs−1, broad hydrogen lines in its optical spectra, and delayed brightening of luminous (LX,peak ∼ 3 × 1043 ergs−1), highly variable soft X-ray emission. The MBH mass of AT2024tvd is 106±1M⊙, at least 10 times lower than its host galaxy’s central black hole mass (≳ 108M⊙). The MBH in AT2024tvd has two possible origins: a wandering MBH from the lower-mass galaxy in a minor merger during the dynamical friction phase or a recoiling MBH ejected by triple
Preclinical Advances in Nuclear Neurology.pptxMahitaLaveti
This presentation explores the latest preclinical advancements in nuclear neurology, emphasizing how molecular imaging techniques are transforming our understanding of neurological diseases at the earliest stages. It highlights the use of radiotracers, such as technetium-99m and fluorine-18, in imaging neuroinflammation, amyloid deposition, and blood-brain barrier (BBB) integrity using modalities like SPECT and PET in small animal models. The talk delves into the development of novel biomarkers, advances in radiopharmaceutical chemistry, and the integration of imaging with therapeutic evaluation in models of Alzheimer’s disease, Parkinson’s disease, stroke, and brain tumors. The session aims to bridge the gap between bench and bedside by showcasing how preclinical nuclear imaging is driving innovation in diagnosis, disease monitoring, and targeted therapy in neurology.
Animal Models for Biological and Clinical Research ppt 2.pptxMahitaLaveti
This presentation provides an in-depth overview of the pivotal role animal models play in advancing both basic biological understanding and clinical research. It covers the selection and classification of animal models—ranging from invertebrates to rodents and higher mammals—and their applications in studying human physiology, disease mechanisms, drug development, and toxicology. Special emphasis is placed on the use of genetically modified models, patient-derived xenografts (PDX), and disease-specific models in cancer, neuroscience, infectious diseases, and metabolic disorders. The talk also addresses ethical considerations, regulatory guidelines, and the principles of the 3Rs (Replacement, Reduction, and Refinement) in animal research
This presentation provides a comprehensive overview of Chemical Warfare Agents (CWAs), focusing on their classification, chemical properties, and historical use. It covers the major categories of CWAs nerve agents, blister agents, choking agents, and blood agents highlighting notorious examples such as sarin, mustard gas, and phosgene. The presentation explains how these agents differ in their physical and chemical nature, modes of exposure, and the devastating effects they can have on human health and the environment. It also revisits significant historical events where these agents were deployed, offering context to their role in shaping warfare strategies across the 20th and 21st centuries.
What sets this presentation apart is its ability to blend scientific clarity with historical depth in a visually engaging format. Viewers will discover how each class of chemical agent presents unique dangers from skin-blistering vesicants to suffocating pulmonary toxins and how their development often paralleled advances in chemistry itself. With concise, well-structured slides and real-world examples, the content appeals to both scientific and general audiences, fostering awareness of the critical need for ethical responsibility in chemical research. Whether you're a student, educator, or simply curious about the darker applications of chemistry, this presentation promises an eye-opening exploration of one of the most feared categories of modern weaponry.
About the Author & Designer
Noor Zulfiqar is a professional scientific writer, researcher, and certified presentation designer with expertise in natural sciences, and other interdisciplinary fields. She is known for creating high-quality academic content and visually engaging presentations tailored for researchers, students, and professionals worldwide. With an excellent academic record, she has authored multiple research publications in reputed international journals and is a member of the American Chemical Society (ACS). Noor is also a certified peer reviewer, recognized for her insightful evaluations of scientific manuscripts across diverse disciplines. Her work reflects a commitment to academic excellence, innovation, and clarity whether through research articles or visually impactful presentations.
For collaborations or custom-designed presentations, contact:
Email: professionalwriter94@outlook.com
Facebook Page: facebook.com/ResearchWriter94
Website: professional-content-writings.jimdosite.com
2. GoLang
• Critics: There is nothing new in Go
• GoLang Designers: The task of programming
language designer "is consolidation not innovation"
• Less is exponentially more – Rob Pike, Go Designer
• Do Less, Enable More – Russ Cox, Go Tech Lead
3. Why new programming language
• Computers are faster but not software development
• Dependency management is critical
• Dynamically typed languages such as Python and JS
• Garbage collection and parallel are not well
supported by popular system languages
• Multicore computers
4. GoLang
• Go Fast
• Go Simple
• Natively complied (similar to C/C++)
• Static typing
• Fully garbage collection supported
• Support for concurrency and networking
• Rich standard library
• System & Server-side programming
• Scalable
• Open source. Inspired by: C, Pascal, CSP
5. Who
• Robert Griesemer, Ken Thompson, and Rob Pike
started the project in late 2007
• By mid 2008 the language was mostly designed and
the implementation (compiler, runtime) starting to
work
• Ian Lance Taylor and Russ Cox joined in 2008
• Lots of help from many others
• Officially announced in November 2009
• March 2012: Go 1.0
7. Go Usages
• Large scale distributed systems
• Cloud: GCP, Cloud Foundry, Heroku…
• Web development
• Scripting
• System programming
• Open-source project
9. Install Go
• The Go Playground: https://go.dev/play/
• Install Go: https://go.dev/dl/
• Visual Studio Code + extension
• Go packages doc: https://pkg.go.dev/
10. First Go Program
• Every Go file starts with
package
• import: packages use
• func main: entry of a Go
program
• Can use semicolons to
separate statements
(optional)
• go run file.go
package main
import "fmt" //comments
func main() {
fmt.Println("Hello world!")
}
12. fmt Package
package main
import "fmt"
func main() {
var name string
fmt.Print("Enter your name: ")
fmt.Scanln(&name)
fmt.Printf("Hello, %s! n", name)
}
13. Variables
• Go is statically typed similar to C, C++, Pascal
• Implicit type declare
var name = " Hello " //name is string type
• Explicit declare
var name string = " Hello "
• Multiple declare
var x, y int
var (
name string
z int
)
• Multiple init
var x, y int = 1, 2
var (
name = " Hello "
z = 10
)
SIMILAR TO PASCAL
14. Variables
• Shorthand syntax
• Explicit declare
name string := " Hello " //no need var, := instead =
• Implicit declare
name := " Hello " //type is string
• Keyword const, cannot change value
const SIZE int = 10
15. Naming convention
• Camel case
• twoWordString
• iAmAPerson
• Global scope
• File scope
• Export global scope: starts with Uppercase
package main
import "fmt" //comments
var numberOne int = 10
var NumberTwo int = 20
func main() {
fmt.Println("Hello world!")
}
17. Primitive Data Types
package main
import "fmt" //comments
func main() {
var a complex64 = 2 + 3i
fmt.Println(a)
fmt.Println(real(a), imag(a))
a = complex(3, 5)
fmt.Println(a)
}
18. Type conversion
• Downsize or upsize
package main
import "fmt" //comments
func main() {
var i int = 1
var j float32 = float32(i)
j = 5.5
i = int(j)
i = 65
var s string = string(i)
}
19. String conversion
• strconv package
package main
import "fmt"
import "strconv"
func main() {
i := 65
var s string = strconv.Itoa(i)
}
21. Enum
• List of constants
package main
import "fmt"
const (
zero = 0
one = 1
two = "two"
)
func main() {
}
22. Enum
• Using iota (default 0)
package main
import "fmt"
const (
zero = iota
one
two
)
func main() {
}
23. Array
• Fixed size
• Index starts at 0
• Declaration
var arr [3]int
• Initialization
nameList := [3]string {"A", "B", "C"}
• Implicit length
var arr […]int = {1, 2, 3}
• Multi dimensional array
var arr2D [2][3]int
24. Array
• Length of array: len(arr)
• Iterating through the array
for i,value := range arr {
fmt.Println(i, value)
}
• Assign array will copy
25. Slice
• Think of slice as dynamic array (but actually NOT)
var slc []int = {1, 2, 3}
//does not contain …
• Using make
slc := make([]int, 3) //len is 3
slc1 := make([]int, 0, 5)
//len is 0, cap is 5
• Append
slc = append(slc, 4)
• Assign slice will make reference. Use copy to duplicate
dup := make([]int, len(slc))
copy(dup, slc)
• Length: len(slc)
26. Slice Operator
• Slice support operator with the syntax
sliceName[low:high]
fmt.Println(slc[0:2])
fmt.Println(slc[0:3])
fmt.Println(slc[1:])
27. Map
• Similar to dictionary: map[key-type]value-type
student := map[int]string {
1: "A",
2: "B",
3: "C",}
• Using make
student := make(map[int]string)
• Length: len(student)
• Add new element: map[newKey] = value
• Delete: delete(map, key)
• Check existed
val, isExisted := student[5]
//val is empty string
• Slice cannot be key. Array is possible
• Assign will make reference
28. Struct
• Top level
type student struct {
id int
name string
grade float32
}
• Inline
studentA := struct {
id int
name string}{id:123,
name:"abc"}
• Access member using dot operator “.”
• Assign will make copy (same as array)
29. Struct
• Literals
student1 := student {
id: 123,
name: "abc",
grade: 5.5,
}
• Struct name and member must be capitalized to be
exported
30. Struct
• Embedded
type Person struct {
name string
age int
}
type Student struct {
Person //embedded by value
grade float32
}
• Access: student1.Person.name, student1.name
• Tag
type Student struct {
Person
grade float32 `grade must be 0 to 100`
}