This is a created article in which the information may have evolved or changed. I was going to write a note about Golang io, but I had to understand the array, slice, string concepts before I learned IO, so I'll write Golang io in the next post. Array: The lengths of the arrays are part of the array type, such as var buffer [256]byte type is [256]byte, len (buffer) always returns 256. Slice: A slice describes a contiguous part of an array, such as var slice = buffer[100:250]. Slice can also be generated from slice, such as var slice2 = Slice[5:10], where the type of slice is []byte. Slice doesn't really store data, it just contains a pointer that points to the data, and you can think of it as such a structure:
Type sliceheader struct { Length int
Capacity int zerothelement *byte}
Where capacity equals the size of the array referred to by slice minus the index of zeroelement. We can also use the Make function to create slice,slice: = makes ([]int, 10, 15) where the second parameter is the length of the slice, and the third parameter is the capacity of slice. or with direct volume slice: = []int{0, 1, 2, 3, 4}.String: You can think of string as a read-only byte slice. For example, var sample string = "\xdb\xb2\x3d" is a byte slice with a length of 3. For Unicode data where non-ASCII is formatted as UTF-8. A Code point is a Unicode value that consists of several bytes. A character character can consist of several code points, or even different code points. Golang uses rune to represent code point, type Int32, and character in Golang normalize into a rune.