This is also the syntax to create a slice given an array:

x := [3]string{"Лайка", "Белка", "Стрелка"}
s := x[:] // a slice referencing the storage of x
Slicing does not copy the slice’s data. It creates a new slice value that points to the original array. This makes slice operations as efficient as manipulating array indices. Therefore, modifying the elements (not the slice itself) of a re-slice modifies the elements of the original slice:

d := []byte{'r', 'o', 'a', 'd'}
e := d[2:]
// e == []byte{'a', 'd'}
e[1] = 'm'
// e == []byte{'a', 'm'}
// d == []byte{'r', 'o', 'a', 'm'}
As we slice s, observe the changes in the slice data structure and their relation to the underlying array:

s = s[2:4]
A slice can also be formed by “slicing” an existing slice or array. Slicing is done by specifying a half-open range with two indices separated by a colon. For example, the expression b[1:4] creates a slice including elements 1 through 3 of b (the indices of the resulting slice will be 0 through 2).

b := []byte{'g', 'o', 'l', 'a', 'n', 'g'}
// b[1:4] == []byte{'o', 'l', 'a'}, sharing the same storage as b
Earlier we sliced s to a length shorter than its capacity. We can grow s to its capacity by slicing it again:

s = s[:cap(s)]
where T stands for the element type of the slice to be created. The make function takes a type, a length, and an optional capacity. When called, make allocates an array and returns a slice that refers to that array.

var s []byte
s = make([]byte, 5, 5)
// s == []byte{0, 0, 0, 0, 0}
The start and end indices of a slice expression are optional; they default to zero and the slice’s length respectively:

// b[:2] == []byte{'g', 'o'}
// b[2:] == []byte{'l', 'a', 'n', 'g'}
// b[:] == b
The length and capacity of a slice can be inspected using the built-in len and cap functions.

len(s) == 5
cap(s) == 5
A slice literal is declared just like an array literal, except you leave out the element count:

letters := []string{"a", "b", "c", "d"}
A slice can be created with the built-in function called make, which has the signature,

func make([]T, len, cap) []T

Recommend

Go Slices: usage and internals Slices

Go Slices: usage and internals Arrays

Go Codewalk: Generating arbitrary text: a Markov chain algorithm

Go

Weekly Snapshot History 2012-03-22 (Go 1 Release Candidate 2)

Weekly Snapshot History 2012-03-27 (Go 1)

Pre-Go 1 Release History r57 (released 2011/05/03) Language

Pre-Go 1 Release History r59 (released 2011/08/01) Packages

Go Release History

Go Canceling in-progress operations Canceling database operations after a timeout

Go Executing SQL statements that don't return data

Go Executing transactions Example

Go Querying for data Handling multiple result sets

Go Querying for data Handling nullable column values

Go Querying for data Querying for multiple rows

Go Querying for data Querying for a single row

Go Avoiding SQL injection risk

Go Using prepared statements How you use prepared statements

Go Opening a database handle Freeing resources

Go Opening a database handle Storing database credentials

Go Opening a database handle Confirming a connection

Go Opening a database handle Opening a database handle Opening with a Connector

Go Opening a database handle Opening a database handle Opening with a connection string

Go Opening a database handle Locating and importing a database driver

Go Call your code from another module

Go Compile and install the application

Go Return greetings for multiple people

Tutorial: Get started with Go Call code in an external package

Tutorial: Get started with Go Write some code

Go Tutorial: Getting started with fuzzing Completed code

Go Tutorial: Getting started with fuzzing Fix the double reverse error Fix the error Run the code

Go Tutorial: Getting started with fuzzing Fix the double reverse error Fix the error Write the code

Go Tutorial: Getting started with fuzzing Fix the double reverse error Diagnose the error Run the code

Go Tutorial: Getting started with fuzzing Fix the double reverse error Diagnose the error Write the code

Go Tutorial: Getting started with fuzzing Fix the invalid string error Fix the error Run the code

Go Tutorial: Getting started with fuzzing Fix the invalid string error Fix the error Write the code

Go Tutorial: Getting started with fuzzing Fix the invalid string error Diagnose the error Run the code

Go Tutorial: Getting started with fuzzing Fix the invalid string error Diagnose the error Write the code

Go Tutorial: Getting started with fuzzing Fix the invalid string error Diagnose the error

Go Tutorial: Getting started with fuzzing Add a fuzz test Run the code

Go Tutorial: Getting started with fuzzing Add a fuzz test Write the code

Go Tutorial: Getting started with fuzzing Add a unit test Run the code