Module 4 · Lesson 1 of 516/50 in the course~8 min
Module lessons (1/5)
Fixed length array
Lesson preview5 hands-on exercises readyCourse Go · Module 4 — Collections
Syntax [N]T, because real arrays are rarely used in Go, array conversion → slice.
What you'll learn in this lesson
- Declare array
[N]Twith fixed length compile-time and understand why[3]intand[4]intare distinct types. - Predict copy by value semantics in function assignment and passing.
- Extract slice views (
a[:],a[low:high:max]) from a backing array and know when to use fixed arrays.
Overview
In Go an array has a fixed size decided at compile time: the length N is an integral part of the type [N]T.
Unlike Python, JavaScript or C (where an array decays to a pointer), in Go an array is a complete value: assigning it or passing it to a function copies every element of it:
Sections covered in this lesson
- 1Declaration and length part of the type
- 2Copy-by-value semantics
- 3From array to slice and limited capacity
- 4Array as key of
map - 5Guided practice
- 6Check for understanding
Pro Lesson · Module 4 — Collections
Unlock "Fixed length array" and the full Course Go curriculum
Syntax `[N]T`, because real arrays are rarely used in Go, array conversion → slice.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course Go plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.