Join David Gassner for an in-depth discussion in this video Storing ordered values in slices, part of Up and Running with Go.
- View Offline
- Exercise Files
- A slice in Go is an abstraction layer…that sits on top of an array.…When you declare a slice, the run time…creates the underlying array for you,…allocates the required memory,…and then returns the requested slice.…Like arrays, all items in a slice have to be…of the same type, but unlike arrays, they're resizable,…and they can be sorted quite easily.…To declare a slice, I'll start with the var keyword,…and then I'll set the name of the slice…and then I'll assign it with the single equals operator.…
Then, I'll use opening and closing…brackets without a number.…This means it's a slice.…If I were to put a number in, that would mean it's an array;…without, it's a slice.…After the brackets, I'll declare the type of the items…in the slice, and then I could assign the values…individually as I did before, or, as I did…with the previous examples with arrays,…I can use a pair of braces, and simply list the items.…I'll list red, green and blue.…
The size of the slice in this example…is inferred from the number of items in the list.…
- 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?
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.