- Why arrays?
- What are arrays in Go?
- Array declaration using default values
- Declaring and assigning. Length of an array
- Overriding index numbers when declaring arrays
- The for loop in Go
- The range loop in Go
- Good news on For Range loops
- Exercise - Print odd numbers from array values
- Solution - Print odd numbers from array values
- Data in arrays is passed by value
- Passing arrays by reference
- Passing a subset range of an array in Go
- Array slices are pointers to array values
- What is a slice?
- Three ways to declare a slice
- Appending new items to a Go slice
- Optional quiz to check your understanding so far
- In Go, strings are line slices, but with a fixed length
- Appending a slice to another slice using the ellipsis (...) operator | also Copy
- Appending a limited slice range of values to another slice
- Adding values to an empty slice
- Optional exercise – a slice of bytes
- Solution – slice of bytes
- Copying slices using the copy() function
- Optional exercise – Copying a slice of integers
- Copying slices to specific target indexes
- Optional exercise on copying slices
- Slice copying exercise demo
- Deleting an item from a slice using append()
- Optional exercise: Deleting two items from a slice using append()
- Exercise result: Deleting two items from a slice using append()
- How to extend a slice using append and make
- Inserting a new item in the middle of a slice using 2 append()s
- Optional exercise: Append two items to the middle of a slice using two append()s
- Answer: Append two items to the middle of a slice
- Optional exercise: Append three items to the end of a slice
- Answer: Append three items to the end of a slice
- Optional exercise: Append an existing slice to the middle of another slice
- Answer: Append an existing slice to the middle of another slice
- Optional exercise: Append an existing slice to the middle of a modified slice
- Answer: Append an existing slice to the middle of a modified slice
- Lecture: Appending data into mixed indexes
- Optional exercise: Append cardinal numbers in the proper order
- Answer: Append cardinal numbers in the proper order
- Optional exercise: Appending three slices to a new slice
- Answer: Appending three slices
- Lecture: Two-dimensional arrays
- RESOURCES: Go Arrays and Slices
- Thank you
What you'll learn
- Learn GO arrays and slices fundamentals with easy but efficient exercises.
- Use these short videos as a GO language reference for reviewing or consulting.
- All exercises are shown in the Golang playground. You just need access to the Internet.
- GO arrays and slice techniques explained in detail as well as Go for/range loops.
- Start learning GO data structures here with arrays and slice exercises. Coding is easy if properly taught.
- This is the second volume in the series. Begin with volume one if you are new to Golang.
- Course has been fully inspected and reviewed on September 2021.
- Use this course to review your understanding of Go arrays and slices.
Description
This is the second volume of the GO Language series by Tony de Araujo. It contains around two hours of videos and exercises designed to make you proficient on Go array and slice structures.
Rather than being a primer, it is a didactic sequential approach with short explanations and exercises. By the end of this tutorial series, you’ll have a solid understanding of arrays and slices in Go, enabling you to choose the right data structure for your specific use case.
Understanding Arrays and Slices in Go
In Go, arrays and slices are essential data structures that allow you to work with ordered sequences of elements.
These collections are particularly useful when dealing with related values.
Here’s a breakdown of the key differences between arrays and slices:
Arrays:
In Go an array is a fixed-size data structure.
Its capacity is defined at creation time and cannot be changed afterward.
Once you allocate an array’s size, it remains constant.
Arrays are suitable when you know the exact number of elements you need.\Example: var myArray [5]int creates an integer array with 5 elements.
Slices:
A slice is a dynamically resizable data structure.
Unlike arrays, slices can grow or shrink as needed.
Slices are built on top of arrays and provide a more flexible way to work with sequences.
They are commonly used when the number of elements is not fixed.
Example: mySlice := []int{1, 2, 3} creates an integer slice.
Why Use Arrays and Slices?
Data Organization: Arrays and slices allow you to group related data together. For instance, you can store a list of temperatures, user IDs, or product prices.
Code Efficiency: By using arrays and slices, you can perform the same operations on multiple values simultaneously. This leads to cleaner and more concise code.
Flexibility: Slices adapt to your needs, making them ideal for scenarios where the size may change dynamically.
Tutorial Series Contents:
1. Introduction: Understand the basics of arrays and slices.
2. Declaration and Initialization: Learn how to declare and initialize arrays and slices.
3. Accessing Elements: Explore methods to access individual elements.
4. Modifying Elements: Discover how to modify array and slice elements.
5. Iterating Over Arrays and Slices: Master loops and range-based iteration.
6. Multidimensional Arrays: Dive into arrays with multiple dimensions.
7. Built-in Functions: Explore useful functions for working with arrays and slices.
By the end of this tutorial series, you’ll have a solid understanding of arrays and slices in Go, enabling you to choose the right data structure for your specific use case.
Other Courses
Complete Comptia Network + IT/ Networking Course
Everything you need to know about Networks & Devices to prepare for your CompTIA Network+ Certification Exam
Swedish Made Easy, Day 1 - Comfortable in 6 days
Follow along Shien learning Swedish 1-on-1 with Felix. After only 30h you'll be comfortable at speaking and writing.
Learn Data Analysis using Pandas and Python (Module 2/3)
Analyze and Manipulate data using using Python and powerful Pandas.
DaVinci Resolve Tutorial – MotionVFX Academy
Improve your skills and learn about essential tips & tricks
Build your first React JS Application
Learn the most popular JavaScript framework on the web by building your first React web app
Cisco VPNs with GNS3 Labs: Practical GRE, IPSec, DMVPN labs
Practice Cisco VPN configurations with GNS3 labs. Study for your CCNA, CCNP or CCIE exams with downloadable GNS3 labs.
About the instructors
- 4.83 Calificación
- 1919 Estudiantes
- 4 Cursos
Tony de Araujo
Tech Writer - Published Author on Programming [Amazon]
Hello, and welcome!
As a seasoned corporate technical instructor with over four decades of teaching experience, I’ve had the privilege of training professionals in person across the United States and abroad. My passion for sharing knowledge drives me to empower students, fostering their growth and success, while constantly rethinking how to teach.
My purpose on Udemy is to create concise and impactful tutorials that cater to both beginners and those looking to refresh their coding syntax skills, even in the era of AI, which I'm carefully beginning to address in some of the exercises. Instead of merely typing out code, programmers will increasingly emphasize problem-solving and designing smart solutions.
For that, however, we must understand syntax the same way we would comprehend math while using a calculator as a tool. This is where my efforts reside: to provide clear and succinct explanations of the Go language.
Here’s what you can expect from my courses on Go syntax, some morphology, and Go semantics:
1. Short and Focused: I believe in brevity without sacrificing depth. My tutorials get straight to the point, ensuring you learn efficiently, but also return to review later.
2. Affordable Learning: Some of my courses are free to enroll, while others come at a modest charge. Your support helps me to continue creating valuable content.
---- // ----
Beyond teaching, I wear several hats:
• Programmer: I love diving into code, solving problems, and building practical applications. I'm also enjoying querying AI for possible solutions while still keeping my skills refreshed.
• Technical Writer: Communicating complex concepts in a clear and accessible manner is my forte. Now, I'm also begging to modestly use artificial intelligence as my go to editor of choice to spot possible problems in my messages.
• Former Corporate Executive: I’ve navigated the corporate world, gaining insights that enrich my teaching.
• Musician: When I’m not coding, you’ll find me strumming my guitar or tinkering with musical compositions.
• Proud Grandfather: Being a grandparent is my best job ever. The joy of sharing stories, teaching solfege, laughter, and life lessons with my grandchildren is immeasurable.
-- Join me on this learning journey, and let’s explore the fascinating world of technology together!
Tips on how to approach and study Go programming in these series
Each of the Go language tutorial-and-review series is self-contained.
However, if you're new to the Go language, please enroll in the following sequence of courses to assure your best understanding of the subject:
Volume 1 = The Go Language: Your First Code Adventure. Don't skip this volume as it contains important concepts.
Volume 2 = The Go Language: Arrays & Slices. This is essential to understand the 3rd volume that follows. It is currently open for free enrolment.
Volume 3 = The Go Language: Maps, Interfaces, and More.
(A possible 4th volume is in the works).
Student feedback
Course Rating
Reviews
perfecto. explica genial. muy didactico
Tony, I think I would dip into my retirement savings to take any courses you offered on programming. You have spoiled me. Any further courses I take on any programming language, perhaps any topic, are going to be evaluated according to the standard and style you have provided in your tutorials. I can't wait to move on to the next part of this series. It's just been a complete joy so far and I wish other instructors would take notice of how you do things.
Very clear explanations. Will definitely review the course again to cement things in.
Darker background to save my eyes is the only possible thing that could make this course better. BUY THIS!
Another excellent course from Tony. The exercises provide a great way to reinforce what is learned during Tony's presentation which are succinct and clearly explained. On to course three....