Join David Gassner for an in-depth discussion in this video Storing ordered values in arrays, part of Up and Running with Go.
- Just like other C-style languages,…an array in Go is an ordered collection of values.…I'll describe the array's basic feature…but also suggest right away…that it's better to use slices than arrays…to represent ordered collections of values.…To declare an array in Go, start with the keyword var.…Then declare the name of the array.…I'll create an array named colors.…Then put the size of the array between brackets…and follow that with the data type.…All items in a single array must be of the same type.…
You can't mix items in the same array.…Next, to set the items in the array,…use indexing syntax just like C or Java.…The first item is indexed at 0…and I'll set that with a value of Red.…Now, notice I am using the single equals character,…not colon equals because the type has already been set…and it doesn't need to be inferred.…I'll copy and paste that a couple times…and then I'll change the indexes and the values…of the additional two items.…
You can output the contents of the array directly…using one of the formatting functions.…
- Installing Go tools
- Creating and compiling a Go workspace
- Exploring variables, constants, and types
- Storing ordered and unordered values
- Grouping related values in structs
- Programming conditional logic and loops
- Defining and calling functions
- Handling errors
- Working with files
- Creating a simple HTTP server
Skill Level Beginner
Using Java to Program Google App Enginewith Patrick Royal2h 4m Intermediate
Google App Engine Essential Trainingwith Joseph Lowery3h 26m Intermediate
1. Getting Started
2. Essential Go Skills
3. Managing Simple Values
4. Managing Complex Types and Collections
5. Managing Program Flow
6. Structuring Go Code
7. Working with Files and the Web
Next steps2m 26s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.